From: Simon Glass Date: Tue, 7 Jun 2016 20:47:58 -0600 Subject: [U-Boot] [PATCH 20/31] dm: syscon: Add support for of-platdata In-Reply-To: <1465354089-3508-1-git-send-email-sjg@chromium.org> References: <1465354089-3508-1-git-send-email-sjg@chromium.org> Message-ID: <1465354089-3508-21-git-send-email-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Provide a new function which can cope with obtaining information from of-platdata instead of the device tree. Signed-off-by: Simon Glass --- drivers/core/syscon-uclass.c | 13 +++++++++++++ include/syscon.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index e03f46a..01bd968 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -29,7 +29,20 @@ static int syscon_pre_probe(struct udevice *dev) { struct syscon_uc_info *priv = dev_get_uclass_priv(dev); + /* + * With OF_PLATDATA we really have no way of knowing the format of + * the device-specific platform data. So we assume that it starts with + * a 'reg' member, and this holds a single address and size. Drivers + * using OF_PLATDATA will need to ensure that this is true. + */ +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct syscon_base_platdata *plat = dev_get_platdata(dev); + + return regmap_init_mem_platdata(dev, plat->reg, ARRAY_SIZE(plat->reg), + &priv->regmap); +#else return regmap_init_mem(dev, &priv->regmap); +#endif } int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp) diff --git a/include/syscon.h b/include/syscon.h index 4593b6e..19c66b3 100644 --- a/include/syscon.h +++ b/include/syscon.h @@ -23,6 +23,12 @@ struct syscon_ops { #define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops) +#if CONFIG_IS_ENABLED(OF_PLATDATA) +struct syscon_base_platdata { + u32 reg[2]; +}; +#endif + /** * syscon_get_regmap() - Get access to a register map * -- 2.8.0.rc3.226.g39d4020