aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Pasternak <vadimp@mellanox.com>2019-06-23 08:16:24 -0400
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-07-03 08:37:32 -0400
commit6b266e91a0715dae9923a2791e0b98165163e91f (patch)
treeb5abad6adcac7a7de82d3b1e4a36ac14349f1d30
parent3dda617a14327fb5f7c796b0cda2d211e9a2169e (diff)
platform/x86: mlx-platform: Move regmap initialization before all drivers activation
Initialize regmap prior drivers starting to allow passing regmap handle to 'i2c_mlxcpld' driver. Signed-off-by: Vadim Pasternak <vadimp@mellanox.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-rw-r--r--drivers/platform/x86/mlx-platform.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
index 983f02b5b106..91bdbc2b854f 100644
--- a/drivers/platform/x86/mlx-platform.c
+++ b/drivers/platform/x86/mlx-platform.c
@@ -159,6 +159,7 @@
159 * @pdev_io_regs - register access platform devices 159 * @pdev_io_regs - register access platform devices
160 * @pdev_fan - FAN platform devices 160 * @pdev_fan - FAN platform devices
161 * @pdev_wd - array of watchdog platform devices 161 * @pdev_wd - array of watchdog platform devices
162 * @regmap: device register map
162 */ 163 */
163struct mlxplat_priv { 164struct mlxplat_priv {
164 struct platform_device *pdev_i2c; 165 struct platform_device *pdev_i2c;
@@ -168,6 +169,7 @@ struct mlxplat_priv {
168 struct platform_device *pdev_io_regs; 169 struct platform_device *pdev_io_regs;
169 struct platform_device *pdev_fan; 170 struct platform_device *pdev_fan;
170 struct platform_device *pdev_wd[MLXPLAT_CPLD_WD_MAX_DEVS]; 171 struct platform_device *pdev_wd[MLXPLAT_CPLD_WD_MAX_DEVS];
172 void *regmap;
171}; 173};
172 174
173/* Regions for LPC I2C controller and LPC base register space */ 175/* Regions for LPC I2C controller and LPC base register space */
@@ -1740,6 +1742,7 @@ static struct mlxreg_core_platform_data *mlxplat_regs_io;
1740static struct mlxreg_core_platform_data *mlxplat_fan; 1742static struct mlxreg_core_platform_data *mlxplat_fan;
1741static struct mlxreg_core_platform_data 1743static struct mlxreg_core_platform_data
1742 *mlxplat_wd_data[MLXPLAT_CPLD_WD_MAX_DEVS]; 1744 *mlxplat_wd_data[MLXPLAT_CPLD_WD_MAX_DEVS];
1745static const struct regmap_config *mlxplat_regmap_config;
1743 1746
1744static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) 1747static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi)
1745{ 1748{
@@ -2018,6 +2021,24 @@ static int __init mlxplat_init(void)
2018 } 2021 }
2019 platform_set_drvdata(mlxplat_dev, priv); 2022 platform_set_drvdata(mlxplat_dev, priv);
2020 2023
2024 mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev->dev,
2025 mlxplat_lpc_resources[1].start, 1);
2026 if (!mlxplat_mlxcpld_regmap_ctx.base) {
2027 err = -ENOMEM;
2028 goto fail_alloc;
2029 }
2030
2031 if (!mlxplat_regmap_config)
2032 mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config;
2033
2034 priv->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL,
2035 &mlxplat_mlxcpld_regmap_ctx,
2036 mlxplat_regmap_config);
2037 if (IS_ERR(priv->regmap)) {
2038 err = PTR_ERR(priv->regmap);
2039 return err;
2040 }
2041
2021 err = mlxplat_mlxcpld_verify_bus_topology(&nr); 2042 err = mlxplat_mlxcpld_verify_bus_topology(&nr);
2022 if (nr < 0) 2043 if (nr < 0)
2023 goto fail_alloc; 2044 goto fail_alloc;
@@ -2042,21 +2063,8 @@ static int __init mlxplat_init(void)
2042 } 2063 }
2043 } 2064 }
2044 2065
2045 mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev->dev, 2066 /* Add hotplug driver */
2046 mlxplat_lpc_resources[1].start, 1); 2067 mlxplat_hotplug->regmap = priv->regmap;
2047 if (!mlxplat_mlxcpld_regmap_ctx.base) {
2048 err = -ENOMEM;
2049 goto fail_platform_mux_register;
2050 }
2051
2052 mlxplat_hotplug->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL,
2053 &mlxplat_mlxcpld_regmap_ctx,
2054 &mlxplat_mlxcpld_regmap_config);
2055 if (IS_ERR(mlxplat_hotplug->regmap)) {
2056 err = PTR_ERR(mlxplat_hotplug->regmap);
2057 goto fail_platform_mux_register;
2058 }
2059
2060 priv->pdev_hotplug = platform_device_register_resndata( 2068 priv->pdev_hotplug = platform_device_register_resndata(
2061 &mlxplat_dev->dev, "mlxreg-hotplug", 2069 &mlxplat_dev->dev, "mlxreg-hotplug",
2062 PLATFORM_DEVID_NONE, 2070 PLATFORM_DEVID_NONE,
@@ -2069,16 +2077,16 @@ static int __init mlxplat_init(void)
2069 } 2077 }
2070 2078
2071 /* Set default registers. */ 2079 /* Set default registers. */
2072 for (j = 0; j < mlxplat_mlxcpld_regmap_config.num_reg_defaults; j++) { 2080 for (j = 0; j < mlxplat_regmap_config->num_reg_defaults; j++) {
2073 err = regmap_write(mlxplat_hotplug->regmap, 2081 err = regmap_write(priv->regmap,
2074 mlxplat_mlxcpld_regmap_default[j].reg, 2082 mlxplat_regmap_config->reg_defaults[j].reg,
2075 mlxplat_mlxcpld_regmap_default[j].def); 2083 mlxplat_regmap_config->reg_defaults[j].def);
2076 if (err) 2084 if (err)
2077 goto fail_platform_mux_register; 2085 goto fail_platform_mux_register;
2078 } 2086 }
2079 2087
2080 /* Add LED driver. */ 2088 /* Add LED driver. */
2081 mlxplat_led->regmap = mlxplat_hotplug->regmap; 2089 mlxplat_led->regmap = priv->regmap;
2082 priv->pdev_led = platform_device_register_resndata( 2090 priv->pdev_led = platform_device_register_resndata(
2083 &mlxplat_dev->dev, "leds-mlxreg", 2091 &mlxplat_dev->dev, "leds-mlxreg",
2084 PLATFORM_DEVID_NONE, NULL, 0, 2092 PLATFORM_DEVID_NONE, NULL, 0,
@@ -2090,7 +2098,7 @@ static int __init mlxplat_init(void)
2090 2098
2091 /* Add registers io access driver. */ 2099 /* Add registers io access driver. */
2092 if (mlxplat_regs_io) { 2100 if (mlxplat_regs_io) {
2093 mlxplat_regs_io->regmap = mlxplat_hotplug->regmap; 2101 mlxplat_regs_io->regmap = priv->regmap;
2094 priv->pdev_io_regs = platform_device_register_resndata( 2102 priv->pdev_io_regs = platform_device_register_resndata(
2095 &mlxplat_dev->dev, "mlxreg-io", 2103 &mlxplat_dev->dev, "mlxreg-io",
2096 PLATFORM_DEVID_NONE, NULL, 0, 2104 PLATFORM_DEVID_NONE, NULL, 0,
@@ -2104,7 +2112,7 @@ static int __init mlxplat_init(void)
2104 2112
2105 /* Add FAN driver. */ 2113 /* Add FAN driver. */
2106 if (mlxplat_fan) { 2114 if (mlxplat_fan) {
2107 mlxplat_fan->regmap = mlxplat_hotplug->regmap; 2115 mlxplat_fan->regmap = priv->regmap;
2108 priv->pdev_fan = platform_device_register_resndata( 2116 priv->pdev_fan = platform_device_register_resndata(
2109 &mlxplat_dev->dev, "mlxreg-fan", 2117 &mlxplat_dev->dev, "mlxreg-fan",
2110 PLATFORM_DEVID_NONE, NULL, 0, 2118 PLATFORM_DEVID_NONE, NULL, 0,
@@ -2119,7 +2127,7 @@ static int __init mlxplat_init(void)
2119 /* Add WD drivers. */ 2127 /* Add WD drivers. */
2120 for (j = 0; j < MLXPLAT_CPLD_WD_MAX_DEVS; j++) { 2128 for (j = 0; j < MLXPLAT_CPLD_WD_MAX_DEVS; j++) {
2121 if (mlxplat_wd_data[j]) { 2129 if (mlxplat_wd_data[j]) {
2122 mlxplat_wd_data[j]->regmap = mlxplat_hotplug->regmap; 2130 mlxplat_wd_data[j]->regmap = priv->regmap;
2123 priv->pdev_wd[j] = platform_device_register_resndata( 2131 priv->pdev_wd[j] = platform_device_register_resndata(
2124 &mlxplat_dev->dev, "mlx-wdt", 2132 &mlxplat_dev->dev, "mlx-wdt",
2125 j, NULL, 0, 2133 j, NULL, 0,
@@ -2133,8 +2141,8 @@ static int __init mlxplat_init(void)
2133 } 2141 }
2134 2142
2135 /* Sync registers with hardware. */ 2143 /* Sync registers with hardware. */
2136 regcache_mark_dirty(mlxplat_hotplug->regmap); 2144 regcache_mark_dirty(priv->regmap);
2137 err = regcache_sync(mlxplat_hotplug->regmap); 2145 err = regcache_sync(priv->regmap);
2138 if (err) 2146 if (err)
2139 goto fail_platform_wd_register; 2147 goto fail_platform_wd_register;
2140 2148