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

soc/tegra: Register SoC device

Move this code from arch/arm/mach-tegra and make it common among 32-bit
and 64-bit Tegra SoCs. This is slightly complicated by the fact that on
32-bit Tegra, the SoC device is used as the parent for all devices that
are instantiated from device tree.

Signed-off-by: Thierry Reding <treding@nvidia.com>

+54 -30
+1 -28
arch/arm/mach-tegra/tegra.c
··· 84 84 85 85 static void __init tegra_dt_init(void) 86 86 { 87 - struct soc_device_attribute *soc_dev_attr; 88 - struct soc_device *soc_dev; 89 - struct device *parent = NULL; 87 + struct device *parent = tegra_soc_device_register(); 90 88 91 - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); 92 - if (!soc_dev_attr) 93 - goto out; 94 - 95 - soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra"); 96 - soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", 97 - tegra_sku_info.revision); 98 - soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", tegra_get_chip_id()); 99 - 100 - soc_dev = soc_device_register(soc_dev_attr); 101 - if (IS_ERR(soc_dev)) { 102 - kfree(soc_dev_attr->family); 103 - kfree(soc_dev_attr->revision); 104 - kfree(soc_dev_attr->soc_id); 105 - kfree(soc_dev_attr); 106 - goto out; 107 - } 108 - 109 - parent = soc_device_to_device(soc_dev); 110 - 111 - /* 112 - * Finished with the static registrations now; fill in the missing 113 - * devices 114 - */ 115 - out: 116 89 of_platform_default_populate(NULL, NULL, parent); 117 90 } 118 91
+5
drivers/soc/tegra/Kconfig
··· 107 107 endif 108 108 endif 109 109 110 + config SOC_TEGRA_FUSE 111 + def_bool y 112 + depends on ARCH_TEGRA 113 + select SOC_BUS 114 + 110 115 config SOC_TEGRA_FLOWCTRL 111 116 bool 112 117
+46 -2
drivers/soc/tegra/fuse/fuse-tegra.c
··· 19 19 #include <linux/device.h> 20 20 #include <linux/kobject.h> 21 21 #include <linux/init.h> 22 - #include <linux/platform_device.h> 22 + #include <linux/io.h> 23 23 #include <linux/of.h> 24 24 #include <linux/of_address.h> 25 - #include <linux/io.h> 25 + #include <linux/platform_device.h> 26 + #include <linux/slab.h> 27 + #include <linux/sys_soc.h> 26 28 27 29 #include <soc/tegra/common.h> 28 30 #include <soc/tegra/fuse.h> ··· 212 210 writel(reg, base + 0x14); 213 211 } 214 212 213 + struct device * __init tegra_soc_device_register(void) 214 + { 215 + struct soc_device_attribute *attr; 216 + struct soc_device *dev; 217 + 218 + attr = kzalloc(sizeof(*attr), GFP_KERNEL); 219 + if (!attr) 220 + return NULL; 221 + 222 + attr->family = kasprintf(GFP_KERNEL, "Tegra"); 223 + attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_sku_info.revision); 224 + attr->soc_id = kasprintf(GFP_KERNEL, "%u", tegra_get_chip_id()); 225 + 226 + dev = soc_device_register(attr); 227 + if (IS_ERR(dev)) { 228 + kfree(attr->soc_id); 229 + kfree(attr->revision); 230 + kfree(attr->family); 231 + kfree(attr); 232 + return ERR_CAST(dev); 233 + } 234 + 235 + return soc_device_to_device(dev); 236 + } 237 + 215 238 static int __init tegra_init_fuse(void) 216 239 { 217 240 const struct of_device_id *match; ··· 338 311 pr_debug("Tegra CPU Speedo ID %d, SoC Speedo ID %d\n", 339 312 tegra_sku_info.cpu_speedo_id, tegra_sku_info.soc_speedo_id); 340 313 314 + 341 315 return 0; 342 316 } 343 317 early_initcall(tegra_init_fuse); 318 + 319 + #ifdef CONFIG_ARM64 320 + static int __init tegra_init_soc(void) 321 + { 322 + struct device *soc; 323 + 324 + soc = tegra_soc_device_register(); 325 + if (IS_ERR(soc)) { 326 + pr_err("failed to register SoC device: %ld\n", PTR_ERR(soc)); 327 + return PTR_ERR(soc); 328 + } 329 + 330 + return 0; 331 + } 332 + device_initcall(tegra_init_soc) 333 + #endif
+2
include/soc/tegra/fuse.h
··· 65 65 66 66 extern struct tegra_sku_info tegra_sku_info; 67 67 68 + struct device *tegra_soc_device_register(void); 69 + 68 70 #endif /* __ASSEMBLY__ */ 69 71 70 72 #endif /* __SOC_TEGRA_FUSE_H__ */