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

ARM: OMAP2+: Use signed value for sysc register offsets

We currently don't know if a revision register exists or not. Zero is
often a valid offset for the revision register. As we are still checking
device tree data against platform data, we will get bogus warnings with
correct device tree data because of incomplete platform data.

Let's fix the issue by using signed offsets and tag the revision registers
that don't exist with -ENODEV, and init the missing ones with the correct
revision register offset.

Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

+34 -13
+11 -10
arch/arm/mach-omap2/omap_hwmod.c
··· 481 481 482 482 sysc = oh->class->sysc; 483 483 484 - if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS) 484 + if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS && sysc->syss_offs > 0) 485 485 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs) 486 486 & SYSS_RESETDONE_MASK), 487 487 MAX_MODULE_SOFTRESET_WAIT, c); ··· 3171 3171 */ 3172 3172 int omap_hwmod_init_reg_offs(struct device *dev, 3173 3173 const struct ti_sysc_module_data *data, 3174 - u32 *rev_offs, u32 *sysc_offs, u32 *syss_offs) 3174 + s32 *rev_offs, s32 *sysc_offs, s32 *syss_offs) 3175 3175 { 3176 - *rev_offs = 0; 3176 + *rev_offs = -ENODEV; 3177 3177 *sysc_offs = 0; 3178 3178 *syss_offs = 0; 3179 3179 3180 - if (data->offsets[SYSC_REVISION] > 0) 3180 + if (data->offsets[SYSC_REVISION] >= 0) 3181 3181 *rev_offs = data->offsets[SYSC_REVISION]; 3182 3182 3183 - if (data->offsets[SYSC_SYSCONFIG] > 0) 3183 + if (data->offsets[SYSC_SYSCONFIG] >= 0) 3184 3184 *sysc_offs = data->offsets[SYSC_SYSCONFIG]; 3185 3185 3186 - if (data->offsets[SYSC_SYSSTATUS] > 0) 3186 + if (data->offsets[SYSC_SYSSTATUS] >= 0) 3187 3187 *syss_offs = data->offsets[SYSC_SYSSTATUS]; 3188 3188 3189 3189 return 0; ··· 3312 3312 struct omap_hwmod *oh, 3313 3313 const struct ti_sysc_module_data *data, 3314 3314 struct sysc_regbits *sysc_fields, 3315 - u32 rev_offs, u32 sysc_offs, 3316 - u32 syss_offs, u32 sysc_flags, 3315 + s32 rev_offs, s32 sysc_offs, 3316 + s32 syss_offs, u32 sysc_flags, 3317 3317 u32 idlemodes) 3318 3318 { 3319 3319 if (!oh->class->sysc) ··· 3365 3365 int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh, 3366 3366 const struct ti_sysc_module_data *data, 3367 3367 struct sysc_regbits *sysc_fields, 3368 - u32 rev_offs, u32 sysc_offs, u32 syss_offs, 3368 + s32 rev_offs, s32 sysc_offs, s32 syss_offs, 3369 3369 u32 sysc_flags, u32 idlemodes) 3370 3370 { 3371 3371 struct omap_hwmod_class_sysconfig *sysc; ··· 3425 3425 { 3426 3426 struct omap_hwmod *oh; 3427 3427 struct sysc_regbits *sysc_fields; 3428 - u32 rev_offs, sysc_offs, syss_offs, sysc_flags, idlemodes; 3428 + s32 rev_offs, sysc_offs, syss_offs; 3429 + u32 sysc_flags, idlemodes; 3429 3430 int error; 3430 3431 3431 3432 if (!dev || !data)
+3 -3
arch/arm/mach-omap2/omap_hwmod.h
··· 317 317 * then this field has to be populated with the correct offset structure. 318 318 */ 319 319 struct omap_hwmod_class_sysconfig { 320 - u32 rev_offs; 321 - u32 sysc_offs; 322 - u32 syss_offs; 320 + s32 rev_offs; 321 + s32 sysc_offs; 322 + s32 syss_offs; 323 323 u16 sysc_flags; 324 324 struct sysc_regbits *sysc_fields; 325 325 u8 srst_udelay;
+1
arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
··· 629 629 630 630 /* 'i2c' class */ 631 631 static struct omap_hwmod_class_sysconfig am33xx_i2c_sysc = { 632 + .rev_offs = 0, 632 633 .sysc_offs = 0x0010, 633 634 .syss_offs = 0x0090, 634 635 .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY |
+4
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
··· 885 885 */ 886 886 887 887 static struct omap_hwmod_class_sysconfig omap3xxx_mcbsp_sysc = { 888 + .rev_offs = -ENODEV, 888 889 .sysc_offs = 0x008c, 889 890 .sysc_flags = (SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_ENAWAKEUP | 890 891 SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET), ··· 991 990 992 991 /* 'mcbsp sidetone' class */ 993 992 static struct omap_hwmod_class_sysconfig omap3xxx_mcbsp_sidetone_sysc = { 993 + .rev_offs = -ENODEV, 994 994 .sysc_offs = 0x0010, 995 995 .sysc_flags = SYSC_HAS_AUTOIDLE, 996 996 .sysc_fields = &omap_hwmod_sysc_type1, ··· 1020 1018 1021 1019 /* SR common */ 1022 1020 static struct omap_hwmod_class_sysconfig omap34xx_sr_sysc = { 1021 + .rev_offs = -ENODEV, 1023 1022 .sysc_offs = 0x24, 1024 1023 .sysc_flags = (SYSC_HAS_CLOCKACTIVITY | SYSC_NO_CACHE), 1025 1024 .sysc_fields = &omap34xx_sr_sysc_fields, ··· 1033 1030 }; 1034 1031 1035 1032 static struct omap_hwmod_class_sysconfig omap36xx_sr_sysc = { 1033 + .rev_offs = -ENODEV, 1036 1034 .sysc_offs = 0x38, 1037 1035 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), 1038 1036 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_ENAWAKEUP |
+1
arch/arm/mach-omap2/omap_hwmod_43xx_data.c
··· 378 378 }; 379 379 380 380 static struct omap_hwmod_class_sysconfig am43xx_qspi_sysc = { 381 + .rev_offs = 0, 381 382 .sysc_offs = 0x0010, 382 383 .sysc_flags = SYSC_HAS_SIDLEMODE, 383 384 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+4
arch/arm/mach-omap2/omap_hwmod_44xx_data.c
··· 1360 1360 */ 1361 1361 1362 1362 static struct omap_hwmod_class_sysconfig omap44xx_i2c_sysc = { 1363 + .rev_offs = 0, 1363 1364 .sysc_offs = 0x0010, 1364 1365 .syss_offs = 0x0090, 1365 1366 .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY | ··· 1635 1634 1636 1635 /* The IP is not compliant to type1 / type2 scheme */ 1637 1636 static struct omap_hwmod_class_sysconfig omap44xx_mcasp_sysc = { 1637 + .rev_offs = 0, 1638 1638 .sysc_offs = 0x0004, 1639 1639 .sysc_flags = SYSC_HAS_SIDLEMODE, 1640 1640 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | ··· 1669 1667 */ 1670 1668 1671 1669 static struct omap_hwmod_class_sysconfig omap44xx_mcbsp_sysc = { 1670 + .rev_offs = -ENODEV, 1672 1671 .sysc_offs = 0x008c, 1673 1672 .sysc_flags = (SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_ENAWAKEUP | 1674 1673 SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET), ··· 2356 2353 2357 2354 /* The IP is not compliant to type1 / type2 scheme */ 2358 2355 static struct omap_hwmod_class_sysconfig omap44xx_smartreflex_sysc = { 2356 + .rev_offs = -ENODEV, 2359 2357 .sysc_offs = 0x0038, 2360 2358 .sysc_flags = (SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE), 2361 2359 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+3
arch/arm/mach-omap2/omap_hwmod_54xx_data.c
··· 804 804 */ 805 805 806 806 static struct omap_hwmod_class_sysconfig omap54xx_i2c_sysc = { 807 + .rev_offs = 0, 807 808 .sysc_offs = 0x0010, 808 809 .syss_offs = 0x0090, 809 810 .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY | ··· 975 974 */ 976 975 977 976 static struct omap_hwmod_class_sysconfig omap54xx_mcbsp_sysc = { 977 + .rev_offs = -ENODEV, 978 978 .sysc_offs = 0x008c, 979 979 .sysc_flags = (SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_ENAWAKEUP | 980 980 SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET), ··· 1999 1997 */ 2000 1998 2001 1999 static struct omap_hwmod_class_sysconfig omap54xx_sata_sysc = { 2000 + .rev_offs = 0x00fc, 2002 2001 .sysc_offs = 0x0000, 2003 2002 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE), 2004 2003 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+6
arch/arm/mach-omap2/omap_hwmod_7xx_data.c
··· 1070 1070 */ 1071 1071 1072 1072 static struct omap_hwmod_class_sysconfig dra7xx_i2c_sysc = { 1073 + .rev_offs = 0, 1073 1074 .sysc_offs = 0x0010, 1074 1075 .syss_offs = 0x0090, 1075 1076 .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY | ··· 1441 1440 * 1442 1441 */ 1443 1442 static struct omap_hwmod_class_sysconfig dra7xx_mcasp_sysc = { 1443 + .rev_offs = 0, 1444 1444 .sysc_offs = 0x0004, 1445 1445 .sysc_flags = SYSC_HAS_SIDLEMODE, 1446 1446 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), ··· 1900 1898 */ 1901 1899 1902 1900 static struct omap_hwmod_class_sysconfig dra7xx_qspi_sysc = { 1901 + .rev_offs = 0, 1903 1902 .sysc_offs = 0x0010, 1904 1903 .sysc_flags = SYSC_HAS_SIDLEMODE, 1905 1904 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | ··· 1933 1930 * 1934 1931 */ 1935 1932 static struct omap_hwmod_class_sysconfig dra7xx_rtcss_sysc = { 1933 + .rev_offs = 0x0074, 1936 1934 .sysc_offs = 0x0078, 1937 1935 .sysc_flags = SYSC_HAS_SIDLEMODE, 1938 1936 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | ··· 1969 1965 */ 1970 1966 1971 1967 static struct omap_hwmod_class_sysconfig dra7xx_sata_sysc = { 1968 + .rev_offs = 0x00fc, 1972 1969 .sysc_offs = 0x0000, 1973 1970 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE), 1974 1971 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | ··· 2008 2003 2009 2004 /* The IP is not compliant to type1 / type2 scheme */ 2010 2005 static struct omap_hwmod_class_sysconfig dra7xx_smartreflex_sysc = { 2006 + .rev_offs = -ENODEV, 2011 2007 .sysc_offs = 0x0038, 2012 2008 .sysc_flags = (SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE), 2013 2009 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+1
arch/arm/mach-omap2/omap_hwmod_81xx_data.c
··· 954 954 }; 955 955 956 956 static struct omap_hwmod_class_sysconfig dm81xx_sata_sysc = { 957 + .rev_offs = 0x00fc, 957 958 .sysc_offs = 0x1100, 958 959 .sysc_flags = SYSC_HAS_SIDLEMODE, 959 960 .idlemodes = SIDLE_FORCE,