History

vexpress: Move setting master site to vexpress-config bus

There's only a single caller of vexpress_config_set_master() from vexpress-sysreg.c. Let's just make the registers needed available to vexpress-config and move all the code there. The registers needed aren't used anywhere else either. With this, we can get rid of the private API between these 2 drivers.

Rob Herring committed 6 years ago

Commit 310f80d1 parent a5a38763 files · +34 −37Browse files

Unified · Split

3 files
  1. drivers/bus/vexpress-config.c +33 −4
  2. drivers/mfd/vexpress-sysreg.c +1 −24
  3. include/linux/vexpress.h +0 −9
drivers/bus/vexpress-config.c+33−4
@@ -14,9 +14,17 @@ · 13 unmodified lines
1414 #include <linux/slab.h>
1515 #include <linux/vexpress.h>
1616
17−#define SYS_CFGDATA 0x0
17+#define SYS_MISC 0x0
18+#define SYS_MISC_MASTERSITE (1 << 14)
1819
19−#define SYS_CFGCTRL 0x4
20+#define SYS_PROCID0 0x24
21+#define SYS_PROCID1 0x28
22+#define SYS_HBI_MASK 0xfff
23+#define SYS_PROCIDx_HBI_SHIFT 0
24+
25+#define SYS_CFGDATA 0x40
26+
27+#define SYS_CFGCTRL 0x44
2028 #define SYS_CFGCTRL_START (1 << 31)
2129 #define SYS_CFGCTRL_WRITE (1 << 30)
2230 #define SYS_CFGCTRL_DCC(n) (((n) & 0xf) << 26)
@@ -25,10 +33,14 @@ · 2 unmodified lines
2533 #define SYS_CFGCTRL_POSITION(n) (((n) & 0xf) << 12)
2634 #define SYS_CFGCTRL_DEVICE(n) (((n) & 0xfff) << 0)
2735
28−#define SYS_CFGSTAT 0x8
36+#define SYS_CFGSTAT 0x48
2937 #define SYS_CFGSTAT_ERR (1 << 1)
3038 #define SYS_CFGSTAT_COMPLETE (1 << 0)
3139
40+#define VEXPRESS_SITE_MB 0
41+#define VEXPRESS_SITE_DB1 1
42+#define VEXPRESS_SITE_DB2 2
43+#define VEXPRESS_SITE_MASTER 0xf
3244
3345 struct vexpress_syscfg {
3446 struct device *dev;
@@ -59,7 +71,7 @@ static DEFINE_MUTEX(vexpress_config_mutex); · 24 unmodified lines
5971 static u32 vexpress_config_site_master = VEXPRESS_SITE_MASTER;
6072
6173
62−void vexpress_config_set_master(u32 site)
74+static void vexpress_config_set_master(u32 site)
6375 {
6476 vexpress_config_site_master = site;
6577 }
@@ -340,6 +352,8 @@ static int vexpress_syscfg_probe(struct platform_device *pdev) · 274 unmodified lines
340352 struct resource *res;
341353 struct vexpress_config_bridge *bridge;
342354 struct device_node *node;
355+ int master;
356+ u32 dt_hbi;
343357
344358 syscfg = devm_kzalloc(&pdev->dev, sizeof(*syscfg), GFP_KERNEL);
345359 if (!syscfg)
@@ -361,6 +375,21 @@ static int vexpress_syscfg_probe(struct platform_device *pdev) · 15 unmodified lines
361375
362376 dev_set_drvdata(&pdev->dev, bridge);
363377
378+ master = readl(syscfg->base + SYS_MISC) & SYS_MISC_MASTERSITE ?
379+ VEXPRESS_SITE_DB2 : VEXPRESS_SITE_DB1;
380+ vexpress_config_set_master(master);
381+
382+ /* Confirm board type against DT property, if available */
383+ if (of_property_read_u32(of_root, "arm,hbi", &dt_hbi) == 0) {
384+ u32 id = readl(syscfg->base + (master == VEXPRESS_SITE_DB1 ?
385+ SYS_PROCID0 : SYS_PROCID1));
386+ u32 hbi = (id >> SYS_PROCIDx_HBI_SHIFT) & SYS_HBI_MASK;
387+
388+ if (WARN_ON(dt_hbi != hbi))
389+ dev_warn(&pdev->dev, "DT HBI (%x) is not matching hardware (%x)!\n",
390+ dt_hbi, hbi);
391+ }
392+
364393 for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") {
365394 struct device_node *bridge_np;
366395
drivers/mfd/vexpress-sysreg.c+1−24
@@ -14,7 +14,6 @@ · 13 unmodified lines
1414 #include <linux/platform_device.h>
1515 #include <linux/slab.h>
1616 #include <linux/stat.h>
17−#include <linux/vexpress.h>
1817
1918 #define SYS_ID 0x000
2019 #define SYS_SW 0x004
@@ -37,11 +36,6 @@ · 16 unmodified lines
3736 #define SYS_CFGCTRL 0x0a4
3837 #define SYS_CFGSTAT 0x0a8
3938
40−#define SYS_HBI_MASK 0xfff
41−#define SYS_PROCIDx_HBI_SHIFT 0
42−
43−#define SYS_MISC_MASTERSITE (1 << 14)
44−
4539 /* The sysreg block is just a random collection of various functions... */
4640
4741 static struct bgpio_pdata vexpress_sysreg_sys_led_pdata = {
@@ -94,7 +88,7 @@ static struct mfd_cell vexpress_sysreg_cells[] = { · 46 unmodified lines
9488 .name = "vexpress-syscfg",
9589 .num_resources = 1,
9690 .resources = (struct resource []) {
97− DEFINE_RES_MEM(SYS_CFGDATA, 0xc),
91+ DEFINE_RES_MEM(SYS_MISC, 0x4c),
9892 },
9993 }
10094 };
@@ -104,8 +98,6 @@ static int vexpress_sysreg_probe(struct platform_device *pdev) · 3 unmodified lines
10498 struct resource *mem;
10599 void __iomem *base;
106100 struct gpio_chip *mmc_gpio_chip;
107− int master;
108− u32 dt_hbi;
109101
110102 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
111103 if (!mem)
@@ -115,21 +107,6 @@ static int vexpress_sysreg_probe(struct platform_device *pdev) · 3 unmodified lines
115107 if (!base)
116108 return -ENOMEM;
117109
118− master = readl(base + SYS_MISC) & SYS_MISC_MASTERSITE ?
119− VEXPRESS_SITE_DB2 : VEXPRESS_SITE_DB1;
120− vexpress_config_set_master(master);
121−
122− /* Confirm board type against DT property, if available */
123− if (of_property_read_u32(of_root, "arm,hbi", &dt_hbi) == 0) {
124− u32 id = readl(base + (master == VEXPRESS_SITE_DB1 ?
125− SYS_PROCID0 : SYS_PROCID1));
126− u32 hbi = (id >> SYS_PROCIDx_HBI_SHIFT) & SYS_HBI_MASK;
127−
128− if (WARN_ON(dt_hbi != hbi))
129− dev_warn(&pdev->dev, "DT HBI (%x) is not matching hardware (%x)!\n",
130− dt_hbi, hbi);
131− }
132−
133110 /*
134111 * Duplicated SYS_MCI pseudo-GPIO controller for compatibility with
135112 * older trees using sysreg node for MMC control lines.
include/linux/vexpress.h+0−9
@@ -10,15 +10,6 @@ · 9 unmodified lines
1010 #include <linux/device.h>
1111 #include <linux/regmap.h>
1212
13−#define VEXPRESS_SITE_MB 0
14−#define VEXPRESS_SITE_DB1 1
15−#define VEXPRESS_SITE_DB2 2
16−#define VEXPRESS_SITE_MASTER 0xf
17−
18−/* Config infrastructure */
19−
20−void vexpress_config_set_master(u32 site);
21−
2213 /* Config regmap API */
2314
2415 struct regmap *devm_regmap_init_vexpress_config(struct device *dev);