| .. | .. |
|---|
| 57 | 57 | } |
|---|
| 58 | 58 | |
|---|
| 59 | 59 | cell = nvmem_cell_get(dev, "id"); |
|---|
| 60 | | - if (IS_ERR(cell)) { |
|---|
| 61 | | - dev_err(dev, "failed to get id cell: %ld\n", PTR_ERR(cell)); |
|---|
| 62 | | - if (PTR_ERR(cell) == -EPROBE_DEFER) |
|---|
| 63 | | - return PTR_ERR(cell); |
|---|
| 64 | | - return PTR_ERR(cell); |
|---|
| 65 | | - } |
|---|
| 60 | + if (IS_ERR(cell)) |
|---|
| 61 | + return dev_err_probe(dev, PTR_ERR(cell), "failed to get id cell\n"); |
|---|
| 62 | + |
|---|
| 66 | 63 | efuse_buf = nvmem_cell_read(cell, &len); |
|---|
| 67 | 64 | nvmem_cell_put(cell); |
|---|
| 68 | 65 | if (IS_ERR(efuse_buf)) |
|---|
| .. | .. |
|---|
| 81 | 78 | |
|---|
| 82 | 79 | kfree(efuse_buf); |
|---|
| 83 | 80 | |
|---|
| 81 | + dev_info(dev, "SoC\t\t: %lx\n", rockchip_soc_id); |
|---|
| 82 | + |
|---|
| 83 | +#ifdef CONFIG_NO_GKI |
|---|
| 84 | 84 | system_serial_low = crc32(0, buf, 8); |
|---|
| 85 | 85 | system_serial_high = crc32(system_serial_low, buf + 8, 8); |
|---|
| 86 | 86 | |
|---|
| 87 | | - dev_info(dev, "SoC\t\t: %lx\n", rockchip_soc_id); |
|---|
| 88 | 87 | dev_info(dev, "Serial\t\t: %08x%08x\n", |
|---|
| 89 | 88 | system_serial_high, system_serial_low); |
|---|
| 89 | +#endif |
|---|
| 90 | 90 | |
|---|
| 91 | 91 | return 0; |
|---|
| 92 | 92 | } |
|---|
| .. | .. |
|---|
| 105 | 105 | }, |
|---|
| 106 | 106 | }; |
|---|
| 107 | 107 | |
|---|
| 108 | +static void rockchip_set_cpu_version_from_os_reg(u32 reg) |
|---|
| 109 | +{ |
|---|
| 110 | + void __iomem *r = ioremap(reg, 0x4); |
|---|
| 111 | + |
|---|
| 112 | + if (r) { |
|---|
| 113 | + rockchip_set_cpu_version(readl_relaxed(r) & GENMASK(2, 0)); |
|---|
| 114 | + iounmap(r); |
|---|
| 115 | + } |
|---|
| 116 | +} |
|---|
| 117 | + |
|---|
| 108 | 118 | static void px30_init(void) |
|---|
| 109 | 119 | { |
|---|
| 110 | 120 | void __iomem *base; |
|---|
| .. | .. |
|---|
| 120 | 130 | rockchip_soc_id = ROCKCHIP_SOC_PX30S; |
|---|
| 121 | 131 | iounmap(base); |
|---|
| 122 | 132 | } |
|---|
| 133 | +} |
|---|
| 134 | + |
|---|
| 135 | +#define RV1106_OS_REG1 0xff020204 |
|---|
| 136 | +static void rv1103_init(void) |
|---|
| 137 | +{ |
|---|
| 138 | + rockchip_soc_id = ROCKCHIP_SOC_RV1103; |
|---|
| 139 | + rockchip_set_cpu_version_from_os_reg(RV1106_OS_REG1); |
|---|
| 140 | +} |
|---|
| 141 | + |
|---|
| 142 | +static void rv1106_init(void) |
|---|
| 143 | +{ |
|---|
| 144 | + rockchip_soc_id = ROCKCHIP_SOC_RV1106; |
|---|
| 145 | + rockchip_set_cpu_version_from_os_reg(RV1106_OS_REG1); |
|---|
| 123 | 146 | } |
|---|
| 124 | 147 | |
|---|
| 125 | 148 | static void rv1109_init(void) |
|---|
| .. | .. |
|---|
| 176 | 199 | #define RK3308_GRF_CHIP_ID 0x800 |
|---|
| 177 | 200 | base = ioremap(RK3308_GRF_PHYS, SZ_4K); |
|---|
| 178 | 201 | if (base) { |
|---|
| 179 | | - if (readl_relaxed(base + RK3308_GRF_CHIP_ID) == 0x3308) |
|---|
| 202 | + u32 v = readl_relaxed(base + RK3308_GRF_CHIP_ID); |
|---|
| 203 | + |
|---|
| 204 | + if (v == 0x3308) |
|---|
| 180 | 205 | rockchip_soc_id = ROCKCHIP_SOC_RK3308B; |
|---|
| 206 | + if (v == 0x3308c) |
|---|
| 207 | + rockchip_soc_id = ROCKCHIP_SOC_RK3308BS; |
|---|
| 181 | 208 | iounmap(base); |
|---|
| 182 | 209 | } |
|---|
| 210 | +} |
|---|
| 211 | + |
|---|
| 212 | +static void rk3528_init(void) |
|---|
| 213 | +{ |
|---|
| 214 | + if (of_machine_is_compatible("rockchip,rk3528")) |
|---|
| 215 | + rockchip_soc_id = ROCKCHIP_SOC_RK3528; |
|---|
| 216 | + else if (of_machine_is_compatible("rockchip,rk3528a")) |
|---|
| 217 | + rockchip_soc_id = ROCKCHIP_SOC_RK3528A; |
|---|
| 183 | 218 | } |
|---|
| 184 | 219 | |
|---|
| 185 | 220 | #define RK356X_PMU_GRF_PHYS 0xfdc20000 |
|---|
| .. | .. |
|---|
| 203 | 238 | rk356x_set_cpu_version(); |
|---|
| 204 | 239 | } |
|---|
| 205 | 240 | |
|---|
| 241 | +static void rk3567_init(void) |
|---|
| 242 | +{ |
|---|
| 243 | + rockchip_soc_id = ROCKCHIP_SOC_RK3567; |
|---|
| 244 | + rk356x_set_cpu_version(); |
|---|
| 245 | +} |
|---|
| 246 | + |
|---|
| 206 | 247 | static void rk3568_init(void) |
|---|
| 207 | 248 | { |
|---|
| 208 | 249 | rockchip_soc_id = ROCKCHIP_SOC_RK3568; |
|---|
| 209 | 250 | rk356x_set_cpu_version(); |
|---|
| 210 | 251 | } |
|---|
| 211 | 252 | |
|---|
| 212 | | -int __init rockchip_soc_id_init(void) |
|---|
| 253 | +int rockchip_soc_id_init(void) |
|---|
| 213 | 254 | { |
|---|
| 214 | 255 | if (rockchip_soc_id) |
|---|
| 215 | 256 | return 0; |
|---|
| .. | .. |
|---|
| 223 | 264 | rk3126_init(); |
|---|
| 224 | 265 | } else if (cpu_is_rk3308()) { |
|---|
| 225 | 266 | rk3308_init(); |
|---|
| 267 | + } else if (cpu_is_rv1103()) { |
|---|
| 268 | + rv1103_init(); |
|---|
| 269 | + } else if (cpu_is_rv1106()) { |
|---|
| 270 | + rv1106_init(); |
|---|
| 226 | 271 | } else if (cpu_is_rv1109()) { |
|---|
| 227 | 272 | rv1109_init(); |
|---|
| 228 | 273 | } else if (cpu_is_rv1126()) { |
|---|
| 229 | 274 | rv1126_init(); |
|---|
| 230 | | - } else if (cpu_is_rk3566()) { |
|---|
| 275 | + } else if (cpu_is_rk3528()) { |
|---|
| 276 | + rk3528_init(); |
|---|
| 277 | + } else if (cpu_is_rk3566()) { |
|---|
| 231 | 278 | rk3566_init(); |
|---|
| 279 | + } else if (cpu_is_rk3567()) { |
|---|
| 280 | + rk3567_init(); |
|---|
| 232 | 281 | } else if (cpu_is_rk3568()) { |
|---|
| 233 | 282 | rk3568_init(); |
|---|
| 234 | 283 | } else if (cpu_is_px30()) { |
|---|
| .. | .. |
|---|
| 237 | 286 | |
|---|
| 238 | 287 | return 0; |
|---|
| 239 | 288 | } |
|---|
| 289 | +EXPORT_SYMBOL(rockchip_soc_id_init); |
|---|
| 240 | 290 | #ifndef MODULE |
|---|
| 241 | 291 | pure_initcall(rockchip_soc_id_init); |
|---|
| 242 | 292 | #endif |
|---|