Kunihiko Hayashi | b0415d8 | 2021-07-06 19:01:08 +0900 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * phy_uniphier_pcie.c - Socionext UniPhier PCIe PHY driver |
| 4 | * Copyright 2019-2021 Socionext, Inc. |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <generic-phy.h> |
| 10 | #include <linux/bitops.h> |
| 11 | #include <linux/compat.h> |
| 12 | #include <regmap.h> |
| 13 | #include <syscon.h> |
| 14 | |
| 15 | /* SG */ |
| 16 | #define SG_USBPCIESEL 0x590 |
| 17 | #define SG_USBPCIESEL_PCIE BIT(0) |
| 18 | |
| 19 | struct uniphier_pciephy_priv { |
| 20 | int dummy; |
| 21 | }; |
| 22 | |
| 23 | static int uniphier_pciephy_init(struct phy *phy) |
| 24 | { |
| 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | static int uniphier_pciephy_probe(struct udevice *dev) |
| 29 | { |
| 30 | struct regmap *regmap; |
| 31 | |
| 32 | regmap = syscon_regmap_lookup_by_phandle(dev, |
| 33 | "socionext,syscon"); |
| 34 | if (!IS_ERR(regmap)) |
| 35 | regmap_update_bits(regmap, SG_USBPCIESEL, |
| 36 | SG_USBPCIESEL_PCIE, SG_USBPCIESEL_PCIE); |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static struct phy_ops uniphier_pciephy_ops = { |
| 42 | .init = uniphier_pciephy_init, |
| 43 | }; |
| 44 | |
| 45 | static const struct udevice_id uniphier_pciephy_ids[] = { |
| 46 | { .compatible = "socionext,uniphier-pro5-pcie-phy" }, |
| 47 | { .compatible = "socionext,uniphier-ld20-pcie-phy" }, |
| 48 | { .compatible = "socionext,uniphier-pxs3-pcie-phy" }, |
| 49 | { } |
| 50 | }; |
| 51 | |
| 52 | U_BOOT_DRIVER(uniphier_pcie_phy) = { |
| 53 | .name = "uniphier-pcie-phy", |
| 54 | .id = UCLASS_PHY, |
| 55 | .of_match = uniphier_pciephy_ids, |
| 56 | .ops = &uniphier_pciephy_ops, |
| 57 | .probe = uniphier_pciephy_probe, |
| 58 | .priv_auto = sizeof(struct uniphier_pciephy_priv), |
| 59 | }; |