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
14#include <linux/slab.h>14#include <linux/slab.h>
15#include <linux/vexpress.h>15#include <linux/vexpress.h>
16 16
17#define SYS_CFGDATA 0x017#define SYS_MISC 0x0
18#define SYS_MISC_MASTERSITE (1 << 14)
18 19
19#define SYS_CFGCTRL 0x420#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
20#define SYS_CFGCTRL_START (1 << 31)28#define SYS_CFGCTRL_START (1 << 31)
21#define SYS_CFGCTRL_WRITE (1 << 30)29#define SYS_CFGCTRL_WRITE (1 << 30)
22#define SYS_CFGCTRL_DCC(n) (((n) & 0xf) << 26)30#define SYS_CFGCTRL_DCC(n) (((n) & 0xf) << 26)
@@ -25,10 +33,14 @@ · 2 unmodified lines
25#define SYS_CFGCTRL_POSITION(n) (((n) & 0xf) << 12)33#define SYS_CFGCTRL_POSITION(n) (((n) & 0xf) << 12)
26#define SYS_CFGCTRL_DEVICE(n) (((n) & 0xfff) << 0)34#define SYS_CFGCTRL_DEVICE(n) (((n) & 0xfff) << 0)
27 35
28#define SYS_CFGSTAT 0x836#define SYS_CFGSTAT 0x48
29#define SYS_CFGSTAT_ERR (1 << 1)37#define SYS_CFGSTAT_ERR (1 << 1)
30#define SYS_CFGSTAT_COMPLETE (1 << 0)38#define SYS_CFGSTAT_COMPLETE (1 << 0)
31 39
40#define VEXPRESS_SITE_MB 0
41#define VEXPRESS_SITE_DB1 1
42#define VEXPRESS_SITE_DB2 2
43#define VEXPRESS_SITE_MASTER 0xf
32 44
33struct vexpress_syscfg {45struct vexpress_syscfg {
34 struct device *dev;46 struct device *dev;
@@ -59,7 +71,7 @@ static DEFINE_MUTEX(vexpress_config_mutex); · 24 unmodified lines
59static u32 vexpress_config_site_master = VEXPRESS_SITE_MASTER;71static u32 vexpress_config_site_master = VEXPRESS_SITE_MASTER;
60 72
61 73
62void vexpress_config_set_master(u32 site)74static void vexpress_config_set_master(u32 site)
63{75{
64 vexpress_config_site_master = site;76 vexpress_config_site_master = site;
65}77}
@@ -340,6 +352,8 @@ static int vexpress_syscfg_probe(struct platform_device *pdev) · 274 unmodified lines
340 struct resource *res;352 struct resource *res;
341 struct vexpress_config_bridge *bridge;353 struct vexpress_config_bridge *bridge;
342 struct device_node *node;354 struct device_node *node;
355 int master;
356 u32 dt_hbi;
343 357
344 syscfg = devm_kzalloc(&pdev->dev, sizeof(*syscfg), GFP_KERNEL);358 syscfg = devm_kzalloc(&pdev->dev, sizeof(*syscfg), GFP_KERNEL);
345 if (!syscfg)359 if (!syscfg)
@@ -361,6 +375,21 @@ static int vexpress_syscfg_probe(struct platform_device *pdev) · 15 unmodified lines
361 375
362 dev_set_drvdata(&pdev->dev, bridge);376 dev_set_drvdata(&pdev->dev, bridge);
363 377
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
364 for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") {393 for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") {
365 struct device_node *bridge_np;394 struct device_node *bridge_np;
366 395
drivers/mfd/vexpress-sysreg.c+1−24
@@ -14,7 +14,6 @@ · 13 unmodified lines
14#include <linux/platform_device.h>14#include <linux/platform_device.h>
15#include <linux/slab.h>15#include <linux/slab.h>
16#include <linux/stat.h>16#include <linux/stat.h>
17#include <linux/vexpress.h>
18 17
19#define SYS_ID 0x00018#define SYS_ID 0x000
20#define SYS_SW 0x00419#define SYS_SW 0x004
@@ -37,11 +36,6 @@ · 16 unmodified lines
37#define SYS_CFGCTRL 0x0a436#define SYS_CFGCTRL 0x0a4
38#define SYS_CFGSTAT 0x0a837#define SYS_CFGSTAT 0x0a8
39 38
40#define SYS_HBI_MASK 0xfff
41#define SYS_PROCIDx_HBI_SHIFT 0
42
43#define SYS_MISC_MASTERSITE (1 << 14)
44
45/* The sysreg block is just a random collection of various functions... */39/* The sysreg block is just a random collection of various functions... */
46 40
47static struct bgpio_pdata vexpress_sysreg_sys_led_pdata = {41static struct bgpio_pdata vexpress_sysreg_sys_led_pdata = {
@@ -94,7 +88,7 @@ static struct mfd_cell vexpress_sysreg_cells[] = { · 46 unmodified lines
94 .name = "vexpress-syscfg",88 .name = "vexpress-syscfg",
95 .num_resources = 1,89 .num_resources = 1,
96 .resources = (struct resource []) {90 .resources = (struct resource []) {
97 DEFINE_RES_MEM(SYS_CFGDATA, 0xc),91 DEFINE_RES_MEM(SYS_MISC, 0x4c),
98 },92 },
99 }93 }
100};94};
@@ -104,8 +98,6 @@ static int vexpress_sysreg_probe(struct platform_device *pdev) · 3 unmodified lines
104 struct resource *mem;98 struct resource *mem;
105 void __iomem *base;99 void __iomem *base;
106 struct gpio_chip *mmc_gpio_chip;100 struct gpio_chip *mmc_gpio_chip;
107 int master;
108 u32 dt_hbi;
109 101
110 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);102 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
111 if (!mem)103 if (!mem)
@@ -115,21 +107,6 @@ static int vexpress_sysreg_probe(struct platform_device *pdev) · 3 unmodified lines
115 if (!base)107 if (!base)
116 return -ENOMEM;108 return -ENOMEM;
117 109
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
133 /*110 /*
134 * Duplicated SYS_MCI pseudo-GPIO controller for compatibility with111 * Duplicated SYS_MCI pseudo-GPIO controller for compatibility with
135 * older trees using sysreg node for MMC control lines.112 * older trees using sysreg node for MMC control lines.
include/linux/vexpress.h+0−9
@@ -10,15 +10,6 @@ · 9 unmodified lines
10#include <linux/device.h>10#include <linux/device.h>
11#include <linux/regmap.h>11#include <linux/regmap.h>
12 12
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
20void vexpress_config_set_master(u32 site);
21
22/* Config regmap API */13/* Config regmap API */
23 14
24struct regmap *devm_regmap_init_vexpress_config(struct device *dev);15struct regmap *devm_regmap_init_vexpress_config(struct device *dev);