From: Roger Quadros Date: Wed, 6 Nov 2019 14:21:16 +0000 (+0200) Subject: phy: ti-pipe3: Introduce mode property in driver data X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=53df65a9d2bafcd6ef01f27888fb7be61e7bbd08;p=u-boot.git phy: ti-pipe3: Introduce mode property in driver data Introduce a mode property in the driver data so that we don't have to keep using "of_device_is_compatible()" throughtout the driver. No functional change. Signed-off-by: Roger Quadros --- diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c index f3b071399c..935dc7afb6 100644 --- a/drivers/phy/ti-pipe3-phy.c +++ b/drivers/phy/ti-pipe3-phy.c @@ -54,14 +54,18 @@ #define PLL_IDLE_TIME 100 /* in milliseconds */ #define PLL_LOCK_TIME 100 /* in milliseconds */ +enum pipe3_mode { PIPE3_MODE_PCIE = 1, + PIPE3_MODE_SATA, + PIPE3_MODE_USBSS }; + struct omap_pipe3 { void __iomem *pll_ctrl_base; void __iomem *power_reg; void __iomem *pll_reset_reg; struct pipe3_dpll_map *dpll_map; + enum pipe3_mode mode; }; - struct pipe3_dpll_params { u16 m; u8 n; @@ -75,6 +79,11 @@ struct pipe3_dpll_map { struct pipe3_dpll_params params; }; +struct pipe3_data { + enum pipe3_mode mode; + struct pipe3_dpll_map *dpll_map; +}; + static inline u32 omap_pipe3_readl(void __iomem *addr, unsigned offset) { return readl(addr + offset); @@ -317,6 +326,7 @@ static int pipe3_phy_probe(struct udevice *dev) fdt_addr_t addr; fdt_size_t sz; struct omap_pipe3 *pipe3 = dev_get_priv(dev); + struct pipe3_data *data; addr = devfdt_get_addr_size_index(dev, 2, &sz); if (addr == FDT_ADDR_T_NONE) { @@ -334,14 +344,16 @@ static int pipe3_phy_probe(struct udevice *dev) if (!pipe3->power_reg) return -EINVAL; - if (device_is_compatible(dev, "ti,phy-pipe3-sata")) { + data = (struct pipe3_data *)dev_get_driver_data(dev); + pipe3->mode = data->mode; + pipe3->dpll_map = data->dpll_map; + + if (pipe3->mode == PIPE3_MODE_SATA) { pipe3->pll_reset_reg = get_reg(dev, "syscon-pllreset"); if (!pipe3->pll_reset_reg) return -EINVAL; } - pipe3->dpll_map = (struct pipe3_dpll_map *)dev_get_driver_data(dev); - return 0; } @@ -365,9 +377,19 @@ static struct pipe3_dpll_map dpll_map_usb[] = { { }, /* Terminator */ }; +static struct pipe3_data data_usb = { + .mode = PIPE3_MODE_USBSS, + .dpll_map = dpll_map_usb, +}; + +static struct pipe3_data data_sata = { + .mode = PIPE3_MODE_SATA, + .dpll_map = dpll_map_sata, +}; + static const struct udevice_id pipe3_phy_ids[] = { - { .compatible = "ti,phy-pipe3-sata", .data = (ulong)&dpll_map_sata }, - { .compatible = "ti,omap-usb3", .data = (ulong)&dpll_map_usb}, + { .compatible = "ti,phy-pipe3-sata", .data = (ulong)&data_sata }, + { .compatible = "ti,omap-usb3", .data = (ulong)&data_usb}, { } };