Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>

+34 -37
+33 -4
drivers/bus/vexpress-config.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/vexpress.h> 16 16 17 - #define SYS_CFGDATA 0x0 17 + #define SYS_MISC 0x0 18 + #define SYS_MISC_MASTERSITE (1 << 14) 18 19 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 20 28 #define SYS_CFGCTRL_START (1 << 31) 21 29 #define SYS_CFGCTRL_WRITE (1 << 30) 22 30 #define SYS_CFGCTRL_DCC(n) (((n) & 0xf) << 26) ··· 33 25 #define SYS_CFGCTRL_POSITION(n) (((n) & 0xf) << 12) 34 26 #define SYS_CFGCTRL_DEVICE(n) (((n) & 0xfff) << 0) 35 27 36 - #define SYS_CFGSTAT 0x8 28 + #define SYS_CFGSTAT 0x48 37 29 #define SYS_CFGSTAT_ERR (1 << 1) 38 30 #define SYS_CFGSTAT_COMPLETE (1 << 0) 39 31 32 + #define VEXPRESS_SITE_MB 0 33 + #define VEXPRESS_SITE_DB1 1 34 + #define VEXPRESS_SITE_DB2 2 35 + #define VEXPRESS_SITE_MASTER 0xf 40 36 41 37 struct vexpress_syscfg { 42 38 struct device *dev; ··· 71 59 static u32 vexpress_config_site_master = VEXPRESS_SITE_MASTER; 72 60 73 61 74 - void vexpress_config_set_master(u32 site) 62 + static void vexpress_config_set_master(u32 site) 75 63 { 76 64 vexpress_config_site_master = site; 77 65 } ··· 352 340 struct resource *res; 353 341 struct vexpress_config_bridge *bridge; 354 342 struct device_node *node; 343 + int master; 344 + u32 dt_hbi; 355 345 356 346 syscfg = devm_kzalloc(&pdev->dev, sizeof(*syscfg), GFP_KERNEL); 357 347 if (!syscfg) ··· 374 360 bridge->context = syscfg; 375 361 376 362 dev_set_drvdata(&pdev->dev, bridge); 363 + 364 + master = readl(syscfg->base + SYS_MISC) & SYS_MISC_MASTERSITE ? 365 + VEXPRESS_SITE_DB2 : VEXPRESS_SITE_DB1; 366 + vexpress_config_set_master(master); 367 + 368 + /* Confirm board type against DT property, if available */ 369 + if (of_property_read_u32(of_root, "arm,hbi", &dt_hbi) == 0) { 370 + u32 id = readl(syscfg->base + (master == VEXPRESS_SITE_DB1 ? 371 + SYS_PROCID0 : SYS_PROCID1)); 372 + u32 hbi = (id >> SYS_PROCIDx_HBI_SHIFT) & SYS_HBI_MASK; 373 + 374 + if (WARN_ON(dt_hbi != hbi)) 375 + dev_warn(&pdev->dev, "DT HBI (%x) is not matching hardware (%x)!\n", 376 + dt_hbi, hbi); 377 + } 377 378 378 379 for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") { 379 380 struct device_node *bridge_np;
+1 -24
drivers/mfd/vexpress-sysreg.c
··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/slab.h> 16 16 #include <linux/stat.h> 17 - #include <linux/vexpress.h> 18 17 19 18 #define SYS_ID 0x000 20 19 #define SYS_SW 0x004 ··· 35 36 #define SYS_CFGDATA 0x0a0 36 37 #define SYS_CFGCTRL 0x0a4 37 38 #define SYS_CFGSTAT 0x0a8 38 - 39 - #define SYS_HBI_MASK 0xfff 40 - #define SYS_PROCIDx_HBI_SHIFT 0 41 - 42 - #define SYS_MISC_MASTERSITE (1 << 14) 43 39 44 40 /* The sysreg block is just a random collection of various functions... */ 45 41 ··· 88 94 .name = "vexpress-syscfg", 89 95 .num_resources = 1, 90 96 .resources = (struct resource []) { 91 - DEFINE_RES_MEM(SYS_CFGDATA, 0xc), 97 + DEFINE_RES_MEM(SYS_MISC, 0x4c), 92 98 }, 93 99 } 94 100 }; ··· 98 104 struct resource *mem; 99 105 void __iomem *base; 100 106 struct gpio_chip *mmc_gpio_chip; 101 - int master; 102 - u32 dt_hbi; 103 107 104 108 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 105 109 if (!mem) ··· 106 114 base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); 107 115 if (!base) 108 116 return -ENOMEM; 109 - 110 - master = readl(base + SYS_MISC) & SYS_MISC_MASTERSITE ? 111 - VEXPRESS_SITE_DB2 : VEXPRESS_SITE_DB1; 112 - vexpress_config_set_master(master); 113 - 114 - /* Confirm board type against DT property, if available */ 115 - if (of_property_read_u32(of_root, "arm,hbi", &dt_hbi) == 0) { 116 - u32 id = readl(base + (master == VEXPRESS_SITE_DB1 ? 117 - SYS_PROCID0 : SYS_PROCID1)); 118 - u32 hbi = (id >> SYS_PROCIDx_HBI_SHIFT) & SYS_HBI_MASK; 119 - 120 - if (WARN_ON(dt_hbi != hbi)) 121 - dev_warn(&pdev->dev, "DT HBI (%x) is not matching hardware (%x)!\n", 122 - dt_hbi, hbi); 123 - } 124 117 125 118 /* 126 119 * Duplicated SYS_MCI pseudo-GPIO controller for compatibility with
-9
include/linux/vexpress.h
··· 10 10 #include <linux/device.h> 11 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 - 20 - void vexpress_config_set_master(u32 site); 21 - 22 13 /* Config regmap API */ 23 14 24 15 struct regmap *devm_regmap_init_vexpress_config(struct device *dev);