phy: rockchip-usb: introduce a common data-struct for the
From: Heiko Stuebner <heiko@...> Date: Tue, 3 Nov 2015 15:16:30 +0100
Commit-Message
This introduces a common struct that holds data belonging to the umbrella device that contains all the phys and that we want to use later. Signed-off-by: Heiko Stuebner <heiko@...>
Patch-Comment
drivers/phy/phy-rockchip-usb.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
Statistics
- 17 lines added
- 7 lines removed
Changes
------------------------ drivers/phy/phy-rockchip-usb.c ------------------------
index dfc056b..dda1994 100644
@@ -36,9 +36,14 @@
#define SIDDQ_ON BIT(13)
#define SIDDQ_OFF (0 << 13)
+struct rockchip_usb_phy_base {
+ struct device *dev;
+ struct regmap *reg_base;
+};
+
struct rockchip_usb_phy {
+ struct rockchip_usb_phy_base *base;
unsigned int reg_offset;
struct clk *clk;
struct phy *phy;
};
@@ -46,7 +51,7 @@ struct rockchip_usb_phy {
static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
bool siddq)
{
+ return regmap_write(phy->base->reg_base, phy->reg_offset,
SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
}
@@ -101,17 +106,23 @@ static void rockchip_usb_phy_action(void *data)
static int rockchip_usb_phy_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ struct rockchip_usb_phy_base *phy_base;
struct rockchip_usb_phy *rk_phy;
struct phy_provider *phy_provider;
struct device_node *child;
unsigned int reg_offset;
int err;
+ phy_base = devm_kzalloc(dev, sizeof(*phy_base), GFP_KERNEL);
+ if (!phy_base)
+ return -ENOMEM;
+
+ phy_base->dev = dev;
+ phy_base->reg_base = syscon_regmap_lookup_by_phandle(dev->of_node,
+ "rockchip,grf");
+ if (IS_ERR(phy_base->reg_base)) {
dev_err(&pdev->dev, "Missing rockchip,grf property\n");
+ return PTR_ERR(phy_base->reg_base);
}
for_each_available_child_of_node(dev->of_node, child) {
@@ -126,7 +137,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
}
rk_phy->reg_offset = reg_offset;
rk_phy->clk = of_clk_get_by_name(child, "phyclk");
if (IS_ERR(rk_phy->clk))