summaryrefslogtreecommitdiff
path: root/src/soc/samsung
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2013-12-09 17:46:22 -0800
committerIsaac Christensen <isaac.christensen@se-eng.com>2014-09-22 18:42:20 +0200
commit03784fa97a764be81ca9bcf79222e7b37e2e7692 (patch)
tree600c7de6cf1c27c3f117bf80bcd52c9e36785faa /src/soc/samsung
parentc505837e67aa4fb89964c849d905fa8d44459152 (diff)
Add check_member macro to allow clean and easy struct offset checking
This patch adds a new static assertion macro that can be used to check the offsets in structures that overlay register sets at compile time. It uses the _Static_assert() declaration from the new ISO C11 standard, which is supported (even without -std=c11) by GCC after version 4.6. (There is supposedly also support in clang, although I haven't tried it... let's deal with compiler issues when/if they turn up.) I've added it to all structures for our current ARM SoCs for now, and I think every new register overlay we add going forward should use them (at least for the last member, but feel free to add more if you think it's useful). Change-Id: If32510e7049739ad05618d363a854dc372d64386 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/179412 Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org> (cherry picked from commit cef5fa13c31375a316ca4556c0039b17c8ea7900) Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com> Reviewed-on: http://review.coreboot.org/6905 Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/soc/samsung')
-rw-r--r--src/soc/samsung/exynos5250/clk.h4
-rw-r--r--src/soc/samsung/exynos5250/dmc.h4
-rw-r--r--src/soc/samsung/exynos5250/dp.h1
-rw-r--r--src/soc/samsung/exynos5250/dsim.h1
-rw-r--r--src/soc/samsung/exynos5250/fimd.h2
-rw-r--r--src/soc/samsung/exynos5250/power.h1
-rw-r--r--src/soc/samsung/exynos5250/spi.h1
-rw-r--r--src/soc/samsung/exynos5250/sysreg.h1
-rw-r--r--src/soc/samsung/exynos5250/tmu.h1
-rw-r--r--src/soc/samsung/exynos5250/trustzone.h1
-rw-r--r--src/soc/samsung/exynos5250/uart.h8
-rw-r--r--src/soc/samsung/exynos5250/usb.h3
-rw-r--r--src/soc/samsung/exynos5420/clk.h2
-rw-r--r--src/soc/samsung/exynos5420/dmc.h4
-rw-r--r--src/soc/samsung/exynos5420/dp.h3
-rw-r--r--src/soc/samsung/exynos5420/dsim.h1
-rw-r--r--src/soc/samsung/exynos5420/fimd.h2
-rw-r--r--src/soc/samsung/exynos5420/i2c.h1
-rw-r--r--src/soc/samsung/exynos5420/power.h1
-rw-r--r--src/soc/samsung/exynos5420/spi.h1
-rw-r--r--src/soc/samsung/exynos5420/sysreg.h1
-rw-r--r--src/soc/samsung/exynos5420/tmu.h1
-rw-r--r--src/soc/samsung/exynos5420/trustzone.h1
-rw-r--r--src/soc/samsung/exynos5420/uart.h8
-rw-r--r--src/soc/samsung/exynos5420/usb.h3
25 files changed, 39 insertions, 18 deletions
diff --git a/src/soc/samsung/exynos5250/clk.h b/src/soc/samsung/exynos5250/clk.h
index f09ac41643..9d27e679ca 100644
--- a/src/soc/samsung/exynos5250/clk.h
+++ b/src/soc/samsung/exynos5250/clk.h
@@ -431,7 +431,7 @@ struct exynos5_clock {
unsigned int clkout_cmu_r1x_div_stat;
unsigned char res98[0x3608];
- unsigned int bpll_lock; /* base + 0x2000c */
+ unsigned int bpll_lock; /* base + 0x20010 */
unsigned char res99[0xfc];
unsigned int bpll_con0;
unsigned int bpll_con1;
@@ -461,6 +461,7 @@ struct exynos5_clock {
unsigned int pll_div2_sel;
unsigned char res109b[0xf5e4];
};
+check_member(exynos5_clock, pll_div2_sel, 0x20a24);
static struct exynos5_clock * const exynos_clock = (void *)EXYNOS5_CLOCK_BASE;
@@ -521,6 +522,7 @@ struct exynos5_mct {
uint8_t reserved14[0x8];
uint32_t l1_wstat;
};
+check_member(exynos5_mct, l1_wstat, 0x440);
static struct exynos5_mct * const exynos_mct =
(void *)EXYNOS5_MULTI_CORE_TIMER_BASE;
diff --git a/src/soc/samsung/exynos5250/dmc.h b/src/soc/samsung/exynos5250/dmc.h
index 6388316c5e..acd9850a04 100644
--- a/src/soc/samsung/exynos5250/dmc.h
+++ b/src/soc/samsung/exynos5250/dmc.h
@@ -115,6 +115,7 @@ struct exynos5_dmc {
unsigned char res34[0xc];
unsigned int pmcnt3_ppc_a;
};
+check_member(exynos5_dmc, pmcnt3_ppc_a, 0xe140);
static struct exynos5_dmc * const exynos_dmc = (void *)EXYNOS5_DMC_CTRL_BASE;
@@ -136,7 +137,7 @@ struct exynos5_phy_control {
unsigned int phy_con14;
unsigned int phy_con15;
unsigned int phy_con16;
- unsigned char res4[4];
+ unsigned char res4[4]; /* NOT a mistake. Yes, it doesn't make sense. */
unsigned int phy_con17;
unsigned int phy_con18;
unsigned int phy_con19;
@@ -164,6 +165,7 @@ struct exynos5_phy_control {
unsigned int phy_con41;
unsigned int phy_con42;
};
+check_member(exynos5_phy_control, phy_con42, 0xac);
static struct exynos5_phy_control * const exynos_phy0_control =
(void *)EXYNOS5_DMC_PHY0_BASE;
diff --git a/src/soc/samsung/exynos5250/dp.h b/src/soc/samsung/exynos5250/dp.h
index b1533c74f7..d031929ef6 100644
--- a/src/soc/samsung/exynos5250/dp.h
+++ b/src/soc/samsung/exynos5250/dp.h
@@ -163,6 +163,7 @@ struct exynos5_dp {
u8 res21[0x3c];
u32 soc_general_ctl;
};
+check_member(exynos5_dp, soc_general_ctl, 0x800);
static struct exynos5_dp * const exynos_dp0 = (void *)EXYNOS5_DP0_BASE;
static struct exynos5_dp * const exynos_dp1 = (void *)EXYNOS5_DP1_BASE;
diff --git a/src/soc/samsung/exynos5250/dsim.h b/src/soc/samsung/exynos5250/dsim.h
index b9245d31e6..b975a106a8 100644
--- a/src/soc/samsung/exynos5250/dsim.h
+++ b/src/soc/samsung/exynos5250/dsim.h
@@ -48,6 +48,7 @@ struct exynos5_dsim {
unsigned int phyacchr;
unsigned int phyacchr1;
};
+check_member(exynos5_dsim, phyacchr1, 0x54);
#define ENABLE 1
#define DISABLE 0
diff --git a/src/soc/samsung/exynos5250/fimd.h b/src/soc/samsung/exynos5250/fimd.h
index 178fb73d08..751e71b05c 100644
--- a/src/soc/samsung/exynos5250/fimd.h
+++ b/src/soc/samsung/exynos5250/fimd.h
@@ -61,6 +61,7 @@ struct exynos5_fimd {
unsigned char res9[0x18];
unsigned int dpclkcon;
};
+check_member(exynos5_fimd, dpclkcon, 0x27c);
static struct exynos5_fimd * const exynos_fimd = (void *)EXYNOS5_FIMD_BASE;
@@ -109,6 +110,7 @@ struct exynos5_disp_ctrl {
unsigned char res2[0x184];
unsigned int trigcon;
};
+check_member(exynos5_disp_ctrl, trigcon, 0x1a4);
static struct exynos5_disp_ctrl * const exynos_disp_ctrl =
(void *)EXYNOS5_DISP1_CTRL_BASE;
diff --git a/src/soc/samsung/exynos5250/power.h b/src/soc/samsung/exynos5250/power.h
index aa93893387..734bb29661 100644
--- a/src/soc/samsung/exynos5250/power.h
+++ b/src/soc/samsung/exynos5250/power.h
@@ -64,6 +64,7 @@ struct exynos5_power {
uint8_t reserved8[0x1e0];
uint32_t ps_hold_ctrl; /* 0x330c */
} __attribute__ ((__packed__));
+check_member(exynos5_power, ps_hold_ctrl, 0x330c);
static struct exynos5_power * const exynos_power = (void*)EXYNOS5_POWER_BASE;
diff --git a/src/soc/samsung/exynos5250/spi.h b/src/soc/samsung/exynos5250/spi.h
index 7ca311444c..4301d42e24 100644
--- a/src/soc/samsung/exynos5250/spi.h
+++ b/src/soc/samsung/exynos5250/spi.h
@@ -39,6 +39,7 @@ struct exynos_spi {
unsigned int fb_clk; /* 0x2c */
unsigned char padding[0xffd0];
};
+check_member(exynos_spi, fb_clk, 0x2c);
#define EXYNOS_SPI_MAX_FREQ 50000000
diff --git a/src/soc/samsung/exynos5250/sysreg.h b/src/soc/samsung/exynos5250/sysreg.h
index 1362177a33..ece9011abf 100644
--- a/src/soc/samsung/exynos5250/sysreg.h
+++ b/src/soc/samsung/exynos5250/sysreg.h
@@ -32,6 +32,7 @@ struct exynos5_sysreg {
unsigned char res2[0x18];
unsigned int usb20_phy_cfg;
};
+check_member(exynos5_sysreg, usb20_phy_cfg, 0x230);
static struct exynos5_sysreg * const exynos_sysreg =
(void *)EXYNOS5_SYSREG_BASE;
diff --git a/src/soc/samsung/exynos5250/tmu.h b/src/soc/samsung/exynos5250/tmu.h
index bda4bd7dd8..34d1f45fef 100644
--- a/src/soc/samsung/exynos5250/tmu.h
+++ b/src/soc/samsung/exynos5250/tmu.h
@@ -57,6 +57,7 @@ struct tmu_reg {
unsigned rsvd15;
unsigned emul_con;
};
+check_member(tmu_reg, emul_con, 0x80);
enum tmu_status_t {
TMU_STATUS_INIT = 0,
diff --git a/src/soc/samsung/exynos5250/trustzone.h b/src/soc/samsung/exynos5250/trustzone.h
index 7b4af9b1f1..4cbb1aa1a5 100644
--- a/src/soc/samsung/exynos5250/trustzone.h
+++ b/src/soc/samsung/exynos5250/trustzone.h
@@ -75,6 +75,7 @@ struct exynos_tzpc {
u32 pcellid2;
u32 pcellid3;
};
+check_member(exynos_tzpc, pcellid3, 0xffc);
void trustzone_init(void);
diff --git a/src/soc/samsung/exynos5250/uart.h b/src/soc/samsung/exynos5250/uart.h
index d324a2f93d..e2514d7b6d 100644
--- a/src/soc/samsung/exynos5250/uart.h
+++ b/src/soc/samsung/exynos5250/uart.h
@@ -21,12 +21,6 @@
#ifndef CPU_SAMSUNG_EXYNOS5250_UART_H
#define CPU_SAMSUNG_EXYNOS5250_UART_H
-/* baudrate rest value */
-union br_rest {
- unsigned short slot; /* udivslot */
- unsigned char value; /* ufracval */
-};
-
struct s5p_uart {
unsigned int ulcon;
unsigned int ucon;
@@ -41,8 +35,8 @@ struct s5p_uart {
unsigned char urxh;
unsigned char res2[3];
unsigned int ubrdiv;
- union br_rest rest;
unsigned char res3[0xffd0];
};
+check_member(s5p_uart, ubrdiv, 0x28);
#endif
diff --git a/src/soc/samsung/exynos5250/usb.h b/src/soc/samsung/exynos5250/usb.h
index ad617da96c..20a22571a2 100644
--- a/src/soc/samsung/exynos5250/usb.h
+++ b/src/soc/samsung/exynos5250/usb.h
@@ -58,6 +58,7 @@ struct exynos5_usb_host_phy {
uint8_t reserved4[4];
uint32_t usbotgtune;
};
+check_member(exynos5_usb_host_phy, usbotgtune, 0x40);
static struct exynos5_usb_host_phy * const exynos_usb_host_phy =
(void *)EXYNOS5_USB_HOST_PHY_BASE;
@@ -81,6 +82,7 @@ struct exynos5_usb_drd_phy {
uint32_t linkhcbelt;
uint32_t linkport;
};
+check_member(exynos5_usb_drd_phy, linkport, 0x44);
static struct exynos5_usb_drd_phy * const exynos_usb_drd_phy =
(void *)EXYNOS5_USB_DRD_PHY_BASE;
@@ -121,6 +123,7 @@ struct exynos5_usb_drd_dwc3 {
uint32_t usb3pipectl;
uint8_t reserved6[60];
};
+check_member(exynos5_usb_drd_dwc3, usb3pipectl, 0x1c0);
static struct exynos5_usb_drd_dwc3 * const exynos_usb_drd_dwc3 =
(void *)EXYNOS5_USB_DRD_DWC3_BASE;
diff --git a/src/soc/samsung/exynos5420/clk.h b/src/soc/samsung/exynos5420/clk.h
index 83d4ad6320..6b7f472c1e 100644
--- a/src/soc/samsung/exynos5420/clk.h
+++ b/src/soc/samsung/exynos5420/clk.h
@@ -596,6 +596,7 @@ struct exynos5420_clock {
uint8_t res148[0x1fdc];
uint32_t cmu_kfc_version; /* 0x1003bff0 */
};
+check_member(exynos5420_clock, cmu_kfc_version, 0x2bff0);
static struct exynos5420_clock * const exynos_clock =
(void *)EXYNOS5_CLOCK_BASE;
@@ -657,6 +658,7 @@ struct exynos5_mct {
uint8_t reserved14[0x8];
uint32_t l1_wstat;
};
+check_member(exynos5_mct, l1_wstat, 0x440);
static struct exynos5_mct * const exynos_mct =
(void *)EXYNOS5_MULTI_CORE_TIMER_BASE;
diff --git a/src/soc/samsung/exynos5420/dmc.h b/src/soc/samsung/exynos5420/dmc.h
index fa7482ae89..d12e2dbeb6 100644
--- a/src/soc/samsung/exynos5420/dmc.h
+++ b/src/soc/samsung/exynos5420/dmc.h
@@ -206,6 +206,7 @@ struct exynos5_dmc {
uint8_t res41[0xc];
uint32_t pmcnt3_ppc; /* 0xe140 */
} __attribute__((packed));
+check_member(exynos5_dmc, pmcnt3_ppc, 0xe140);
static struct exynos5_dmc * const exynos_drex0 = (void *)EXYNOS5420_DMC_DREXI_0;
static struct exynos5_dmc * const exynos_drex1 = (void *)EXYNOS5420_DMC_DREXI_1;
@@ -228,7 +229,7 @@ struct exynos5_phy_control {
uint32_t phy_con14;
uint32_t phy_con15;
uint32_t phy_con16;
- uint8_t res4[4];
+ uint8_t res4[4]; /* NOT a mistake. Yes, it doesn't make sense. */
uint32_t phy_con17;
uint32_t phy_con18;
uint32_t phy_con19;
@@ -256,6 +257,7 @@ struct exynos5_phy_control {
uint32_t phy_con41;
uint32_t phy_con42;
} __attribute__((packed));
+check_member(exynos5_phy_control, phy_con42, 0xac);
static struct exynos5_phy_control * const exynos_phy0_control =
(void *)EXYNOS5_DMC_PHY0_BASE;
diff --git a/src/soc/samsung/exynos5420/dp.h b/src/soc/samsung/exynos5420/dp.h
index 9131b0853c..5c577089b5 100644
--- a/src/soc/samsung/exynos5420/dp.h
+++ b/src/soc/samsung/exynos5420/dp.h
@@ -210,6 +210,7 @@ struct exynos_dp {
u32 test_pattern_gen_en;
u32 test_pattern_gen_ctrl;
};
+check_member(exynos_dp, phy_ctrl, 0x924);
static struct exynos_dp * const exynos_dp0 = (void *)EXYNOS5_DP0_BASE;
static struct exynos_dp * const exynos_dp1 = (void *)EXYNOS5_DP1_BASE;
@@ -882,7 +883,7 @@ struct exynos_fb {
u8 res16[16];
u32 dp_mie_clkcon;
};
-
+/* TODO: can't decipher this, someone add a check_member() please */
/* LCD IF register offset */
#define EXYNOS5_LCD_IF_BASE_OFFSET 0x20000
diff --git a/src/soc/samsung/exynos5420/dsim.h b/src/soc/samsung/exynos5420/dsim.h
index 25015a26ad..9ad55d71c9 100644
--- a/src/soc/samsung/exynos5420/dsim.h
+++ b/src/soc/samsung/exynos5420/dsim.h
@@ -48,6 +48,7 @@ struct exynos5_dsim {
unsigned int phyacchr;
unsigned int phyacchr1;
};
+check_member(exynos5_dsim, phyacchr1, 0x54);
#define ENABLE 1
#define DISABLE 0
diff --git a/src/soc/samsung/exynos5420/fimd.h b/src/soc/samsung/exynos5420/fimd.h
index ce8773fd17..41e5ccd827 100644
--- a/src/soc/samsung/exynos5420/fimd.h
+++ b/src/soc/samsung/exynos5420/fimd.h
@@ -61,6 +61,7 @@ struct exynos5_fimd {
u8 res9[0x18];
u32 dpclkcon;
};
+check_member(exynos5_fimd, dpclkcon, 0x27c);
#define W0_SHADOW_PROTECT (0x1 << 10)
#define COMPKEY_F 0xffffff
@@ -107,6 +108,7 @@ struct exynos5_disp_ctrl {
u8 res2[0x184];
u32 trigcon;
};
+check_member(exynos5_disp_ctrl, trigcon, 0x1a4);
#define VCLK_RISING_EDGE (1 << 7)
#define VCLK_RUNNING (1 << 9)
diff --git a/src/soc/samsung/exynos5420/i2c.h b/src/soc/samsung/exynos5420/i2c.h
index e8fe8201db..3d0a7a2d18 100644
--- a/src/soc/samsung/exynos5420/i2c.h
+++ b/src/soc/samsung/exynos5420/i2c.h
@@ -61,6 +61,7 @@ struct exynos5_hsi2c {
u32 usi_timing_sla;
u32 i2c_addr;
} __attribute__ ((packed));
+check_member(exynos5_hsi2c, i2c_addr, 0x70);
struct s3c24x0_i2c_bus {
int bus_num;
diff --git a/src/soc/samsung/exynos5420/power.h b/src/soc/samsung/exynos5420/power.h
index fd1eac5768..76507673a0 100644
--- a/src/soc/samsung/exynos5420/power.h
+++ b/src/soc/samsung/exynos5420/power.h
@@ -77,6 +77,7 @@ struct exynos5_power {
uint8_t reservedC[0x120];
uint32_t ps_hold_ctrl; /* 0x330c */
} __attribute__ ((__packed__));
+check_member(exynos5_power, ps_hold_ctrl, 0x330c);
static struct exynos5_power * const exynos_power = (void*)EXYNOS5_POWER_BASE;
diff --git a/src/soc/samsung/exynos5420/spi.h b/src/soc/samsung/exynos5420/spi.h
index 94b4fdaace..20c2adb087 100644
--- a/src/soc/samsung/exynos5420/spi.h
+++ b/src/soc/samsung/exynos5420/spi.h
@@ -39,6 +39,7 @@ struct exynos_spi {
unsigned int fb_clk; /* 0x2c */
unsigned char padding[0xffd0];
};
+check_member(exynos_spi, fb_clk, 0x2c);
#define EXYNOS_SPI_MAX_FREQ 50000000
diff --git a/src/soc/samsung/exynos5420/sysreg.h b/src/soc/samsung/exynos5420/sysreg.h
index fa25def318..c73020d752 100644
--- a/src/soc/samsung/exynos5420/sysreg.h
+++ b/src/soc/samsung/exynos5420/sysreg.h
@@ -32,6 +32,7 @@ struct exynos5_sysreg {
unsigned char res2[0x18];
unsigned int usb20_phy_cfg;
};
+check_member(exynos5_sysreg, usb20_phy_cfg, 0x230);
static struct exynos5_sysreg * const exynos_sysreg =
(void *)EXYNOS5_SYSREG_BASE;
diff --git a/src/soc/samsung/exynos5420/tmu.h b/src/soc/samsung/exynos5420/tmu.h
index cf81b9ad33..3085b0718e 100644
--- a/src/soc/samsung/exynos5420/tmu.h
+++ b/src/soc/samsung/exynos5420/tmu.h
@@ -57,6 +57,7 @@ struct tmu_reg {
unsigned rsvd15;
unsigned emul_con;
};
+check_member(tmu_reg, emul_con, 0x80);
enum tmu_status_t {
TMU_STATUS_INIT = 0,
diff --git a/src/soc/samsung/exynos5420/trustzone.h b/src/soc/samsung/exynos5420/trustzone.h
index 69e683aeba..209cd9f354 100644
--- a/src/soc/samsung/exynos5420/trustzone.h
+++ b/src/soc/samsung/exynos5420/trustzone.h
@@ -75,6 +75,7 @@ struct exynos_tzpc {
u32 pcellid2;
u32 pcellid3;
};
+check_member(exynos_tzpc, pcellid3, 0xffc);
void trustzone_init(void);
diff --git a/src/soc/samsung/exynos5420/uart.h b/src/soc/samsung/exynos5420/uart.h
index 72a5789b6d..ed78f60cc3 100644
--- a/src/soc/samsung/exynos5420/uart.h
+++ b/src/soc/samsung/exynos5420/uart.h
@@ -21,12 +21,6 @@
#ifndef CPU_SAMSUNG_EXYNOS5420_UART_H
#define CPU_SAMSUNG_EXYNOS5420_UART_H
-/* baudrate rest value */
-union br_rest {
- unsigned short slot; /* udivslot */
- unsigned char value; /* ufracval */
-};
-
struct s5p_uart {
unsigned int ulcon;
unsigned int ucon;
@@ -41,8 +35,8 @@ struct s5p_uart {
unsigned char urxh;
unsigned char res2[3];
unsigned int ubrdiv;
- union br_rest rest;
unsigned char res3[0xffd0];
};
+check_member(s5p_uart, ubrdiv, 0x28);
#endif
diff --git a/src/soc/samsung/exynos5420/usb.h b/src/soc/samsung/exynos5420/usb.h
index b3c2a33fd6..599b944719 100644
--- a/src/soc/samsung/exynos5420/usb.h
+++ b/src/soc/samsung/exynos5420/usb.h
@@ -58,6 +58,7 @@ struct exynos5_usb_host_phy {
uint8_t reserved4[4];
uint32_t usbotgtune;
};
+check_member(exynos5_usb_host_phy, usbotgtune, 0x40);
static struct exynos5_usb_host_phy * const exynos_usb_host_phy =
(void *)EXYNOS5_USB_HOST_PHY_BASE;
@@ -81,6 +82,7 @@ struct exynos5_usb_drd_phy {
uint32_t linkhcbelt;
uint32_t linkport;
};
+check_member(exynos5_usb_drd_phy, linkport, 0x44);
static struct exynos5_usb_drd_phy * const exynos_usb_drd0_phy =
(void *)EXYNOS5420_USB_DRD0_PHY_BASE;
@@ -123,6 +125,7 @@ struct exynos5_usb_drd_dwc3 {
uint32_t usb3pipectl;
uint8_t reserved6[60];
};
+check_member(exynos5_usb_drd_dwc3, usb3pipectl, 0x1c0);
static struct exynos5_usb_drd_dwc3 * const exynos_usb_drd0_dwc3 =
(void *)EXYNOS5420_USB_DRD0_DWC3_BASE;