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