Skip to contentSkip to conversation

bsp: add SoC driver to brcmstb

PATCH Superseded Justin Chen 2 participants 2 messages Mar 11, 2016

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bsp: add SoC driver to brcmstb

From: Justin Chen <[email protected]>

Value of soc_dev_attributes:
family = chip family id
soc_id = product id
revision = product revision

---
 arch/arm/mach-bcm/Kconfig    |    1 +
 drivers/soc/brcmstb/common.c |   58 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
arch/arm/mach-bcm/Kconfig +1 -0
index 7ef1214..b95ea11 100644
@@ -179,6 +179,7 @@ config ARCH_BRCMSTB
 	select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select SOC_BRCMSTB
+	select SOC_BUS
 	help
 	  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
 	  chipset.
drivers/soc/brcmstb/common.c +58 -0

71 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Justin Chen

From: Justin Chen <[email protected]>

Value of soc_dev_attributes:
family = chip family id
soc_id = product id
revision = product revision

[]

drivers/soc/brcmstb/common.c

Quoted 1 line
drivers/soc/brcmstb/common.c +0 -0

[]

Quoted 21 lines
drivers/soc/brcmstb/common.c +21 -0
+static int __init brcmstb_soc_device_init(void)
+{
+	struct soc_device_attribute *soc_dev_attr;
+	struct soc_device *soc_dev;
+	struct device_node *sun_top_ctrl;
+	void __iomem *sun_top_ctrl_base;
+
+	sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match);
+	if (!sun_top_ctrl)
+		return -ENODEV;
+
+	sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0);
+	if (!sun_top_ctrl_base)
+		return -ENODEV;
+
+	family_id = readl(sun_top_ctrl_base);
+	product_id = readl(sun_top_ctrl_base + 0x4);
+
+	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
+	if (!soc_dev_attr)
+		return -ENOMEM;

drivers/soc/brcmstb/common.c bool soc_is_brcmstb(void)

Quoted 10 lines
drivers/soc/brcmstb/common.c +10 -0
+
+	soc_dev_attr->family = kasprintf(GFP_KERNEL, "%x",
+					family_id >> 28 ?
+					family_id >> 16 : family_id >> 8);
+	soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%x",
+					product_id >> 28 ?
+					product_id >> 16 : product_id >> 8);
+	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c%d",
+				????(char)(((product_id & 0xff) >> 4) + 65),
+				?????product_id & 0xf);

This might be easier to read as:

	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c%d"
					   ((product_id & 0xf0) >> 4) + 'A',
					   product_id & 0xf);

drivers/soc/brcmstb/common.c bool soc_is_brcmstb(void) · line 86

Quoted 8 lines
drivers/soc/brcmstb/common.c +8 -0
+
+	soc_dev = soc_device_register(soc_dev_attr);
+	if (IS_ERR(soc_dev)) {
+		kfree(soc_dev_attr->family);
+		kfree(soc_dev_attr->soc_id);
+		kfree(soc_dev_attr->revision);
+		kfree(soc_dev_attr);
+		return -1;

Mixing GENERIC_ERRNO types and fixed values seems odd. Is -EPERM the correct return here? Maybe -ENODEV?

Quoted 5 lines
drivers/soc/brcmstb/common.c +5 -0
+	}
+
+	return 0;
+}
+arch_initcall(brcmstb_soc_device_init);