summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2013-09-16 22:34:59 (GMT)
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-17 03:22:06 (GMT)
commitc45a6bbb50d84c8a7b45db841dcc1bc57bb895a8 (patch)
tree036500685108b7d8cc94c3d97efb2de73059e85f
parentb2096fa3d1b7d28026c67d5bc16db742a25668fb (diff)
downloaddepthcharge-stabilize-4701.B.tar.gz
depthcharge-stabilize-4701.B.tar.xz
Refactor driver instantiations to take uintptr_t instead of void *stabilize-4701.B
Depthcharge driver instatiation routines all follow the pattern new_device(void *base_address) and are always called from a board.c file with an integer literal that is casted twice ((void *)(uintptr_t)). In order to preserve the sanity of future developers, let's remove that boilerplate and make the functions accept uintptr_t integer literals directly. BUG=None TEST=None Change-Id: I5b881bae1a8274f10cd756c356ff4b0f73f043ed Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169656 Reviewed-by: Gabe Black <gabeblack@chromium.org>
-rw-r--r--src/board/daisy/board.c27
-rw-r--r--src/board/peach_kirby/board.c15
-rw-r--r--src/board/peach_pit/board.c21
-rw-r--r--src/drivers/bus/i2c/exynos5_usi.c4
-rw-r--r--src/drivers/bus/i2c/exynos5_usi.h2
-rw-r--r--src/drivers/bus/i2c/s3c24x0.c4
-rw-r--r--src/drivers/bus/i2c/s3c24x0.h2
-rw-r--r--src/drivers/bus/i2s/exynos5.c8
-rw-r--r--src/drivers/bus/i2s/exynos5.h4
-rw-r--r--src/drivers/bus/spi/exynos5.c4
-rw-r--r--src/drivers/bus/spi/exynos5.h2
-rw-r--r--src/drivers/bus/usb/usb.c2
-rw-r--r--src/drivers/bus/usb/usb.h2
-rw-r--r--src/drivers/storage/dw_mmc.c4
-rw-r--r--src/drivers/storage/dw_mmc.h2
-rw-r--r--src/drivers/storage/exynos_mshc.h2
-rw-r--r--src/drivers/storage/s5p_mshc.c4
17 files changed, 49 insertions, 60 deletions
diff --git a/src/board/daisy/board.c b/src/board/daisy/board.c
index f693c2a..510de90 100644
--- a/src/board/daisy/board.c
+++ b/src/board/daisy/board.c
@@ -41,7 +41,7 @@
#include "drivers/tpm/tis_i2c.h"
#include "vboot/util/flag.h"
-static uint32_t *i2c_cfg = (uint32_t *)(uintptr_t)(0x10050000 + 0x234);
+static uint32_t *i2c_cfg = (uint32_t *)(0x10050000 + 0x234);
static int board_setup(void)
{
@@ -54,9 +54,9 @@ static int board_setup(void)
// Switch from hi speed I2C to the normal one.
writel(0x0, i2c_cfg);
- S3c24x0I2c *i2c3 = new_s3c24x0_i2c((void *)(uintptr_t)0x12c90000);
- S3c24x0I2c *i2c4 = new_s3c24x0_i2c((void *)(uintptr_t)0x12ca0000);
- S3c24x0I2c *i2c7 = new_s3c24x0_i2c((void *)(uintptr_t)0x12cd0000);
+ S3c24x0I2c *i2c3 = new_s3c24x0_i2c(0x12c90000);
+ S3c24x0I2c *i2c4 = new_s3c24x0_i2c(0x12ca0000);
+ S3c24x0I2c *i2c7 = new_s3c24x0_i2c(0x12cd0000);
if (!i2c3 || !i2c4 || !i2c7)
return 1;
@@ -76,15 +76,14 @@ static int board_setup(void)
tis_set_i2c_bus(&i2c3->ops);
- Exynos5Spi *spi1 = new_exynos5_spi((void *)(uintptr_t)0x12d30000);
+ Exynos5Spi *spi1 = new_exynos5_spi(0x12d30000);
if (!spi1)
return 1;
SpiFlash *flash = new_spi_flash(&spi1->ops, 0x400000);
if (!flash || flash_set_ops(&flash->ops))
return 1;
- Exynos5I2s *i2s1 = new_exynos5_i2s((void *)(uintptr_t)0x12d60000,
- 16, 2, 256);
+ Exynos5I2s *i2s1 = new_exynos5_i2s(0x12d60000, 16, 2, 256);
I2sSource *i2s_source = new_i2s_source(&i2s1->ops, 48000, 2, 16000);
if (!i2s_source)
return 1;
@@ -100,10 +99,10 @@ static int board_setup(void)
if (sound_set_ops(&sound_route->ops))
return 1;
- MshciHost *emmc = new_mshci_host((void *)(uintptr_t)0x12200000,
- 400000000, 8, 0, 0x03030001);
- MshciHost *sd_card = new_mshci_host((void *)(uintptr_t)0x12220000,
- 400000000, 4, 1, 0x03020001);
+ MshciHost *emmc = new_mshci_host(0x12200000, 400000000,
+ 8, 0, 0x03030001);
+ MshciHost *sd_card = new_mshci_host(0x12220000, 400000000,
+ 4, 1, 0x03020001);
if (!emmc || !sd_card)
return 1;
list_insert_after(&emmc->mmc.ctrlr.list_node,
@@ -114,10 +113,8 @@ static int board_setup(void)
if (power_set_ops(&exynos_power_ops))
return 1;
- UsbHostController *usb_drd = new_usb_hc(XHCI,
- (void *)(uintptr_t)0x12000000);
- UsbHostController *usb_host = new_usb_hc(EHCI,
- (void *)(uintptr_t)0x12110000);
+ UsbHostController *usb_drd = new_usb_hc(XHCI, 0x12000000);
+ UsbHostController *usb_host = new_usb_hc(EHCI, 0x12110000);
if (!usb_host || !usb_drd)
return 1;
diff --git a/src/board/peach_kirby/board.c b/src/board/peach_kirby/board.c
index f62c80d..f0512d8 100644
--- a/src/board/peach_kirby/board.c
+++ b/src/board/peach_kirby/board.c
@@ -42,14 +42,14 @@ static int board_setup(void)
return 1;
Exynos5UsiI2c *i2c9 =
- new_exynos5_usi_i2c((void *)(uintptr_t)0x12e10000, 400000);
+ new_exynos5_usi_i2c(0x12e10000, 400000);
if (!i2c9)
return 1;
tis_set_i2c_bus(&i2c9->ops);
- Exynos5Spi *spi1 = new_exynos5_spi((void *)(uintptr_t)0x12d30000);
- Exynos5Spi *spi2 = new_exynos5_spi((void *)(uintptr_t)0x12d40000);
+ Exynos5Spi *spi1 = new_exynos5_spi(0x12d30000);
+ Exynos5Spi *spi2 = new_exynos5_spi(0x12d40000);
if (!spi1 || !spi2)
return 1;
@@ -62,8 +62,7 @@ static int board_setup(void)
if (!flash || flash_set_ops(&flash->ops))
return 1;
- DwmciHost *emmc = new_dwmci_host((void *)(uintptr_t)0x12200000,
- 100000000, 8, 0,
+ DwmciHost *emmc = new_dwmci_host(0x12200000, 100000000, 8, 0,
DWMCI_SET_SAMPLE_CLK(1) |
DWMCI_SET_DRV_CLK(3) |
DWMCI_SET_DIV_RATIO(3));
@@ -75,10 +74,8 @@ static int board_setup(void)
if (power_set_ops(&exynos_power_ops))
return 1;
- UsbHostController *usb_drd0 = new_usb_hc(XHCI,
- (void *)(uintptr_t)0x12000000);
- UsbHostController *usb_drd1 = new_usb_hc(XHCI,
- (void *)(uintptr_t)0x12400000);
+ UsbHostController *usb_drd0 = new_usb_hc(XHCI, 0x12000000);
+ UsbHostController *usb_drd1 = new_usb_hc(XHCI, 0x12400000);
if (!usb_drd0 || !usb_drd1)
return 1;
diff --git a/src/board/peach_pit/board.c b/src/board/peach_pit/board.c
index 8869b81..91aa2a5 100644
--- a/src/board/peach_pit/board.c
+++ b/src/board/peach_pit/board.c
@@ -46,14 +46,14 @@ static int board_setup(void)
return 1;
Exynos5UsiI2c *i2c9 =
- new_exynos5_usi_i2c((void *)(uintptr_t)0x12e10000, 400000);
+ new_exynos5_usi_i2c(0x12e10000, 400000);
if (!i2c9)
return 1;
tis_set_i2c_bus(&i2c9->ops);
- Exynos5Spi *spi1 = new_exynos5_spi((void *)(uintptr_t)0x12d30000);
- Exynos5Spi *spi2 = new_exynos5_spi((void *)(uintptr_t)0x12d40000);
+ Exynos5Spi *spi1 = new_exynos5_spi(0x12d30000);
+ Exynos5Spi *spi2 = new_exynos5_spi(0x12d40000);
if (!spi1 || !spi2)
return 1;
@@ -66,8 +66,7 @@ static int board_setup(void)
if (!flash || flash_set_ops(&flash->ops))
return 1;
- Exynos5I2s *i2s0 = new_exynos5_i2s_multi(
- (void *)(uintptr_t)0x03830000, 16, 2, 256);
+ Exynos5I2s *i2s0 = new_exynos5_i2s_multi(0x03830000, 16, 2, 256);
I2sSource *i2s_source = new_i2s_source(&i2s0->ops, 48000, 2, 16000);
if (!i2s_source)
return 1;
@@ -77,13 +76,11 @@ static int board_setup(void)
if (sound_set_ops(&sound_route->ops))
return 1;
- DwmciHost *emmc = new_dwmci_host((void *)(uintptr_t)0x12200000,
- 100000000, 8, 0,
+ DwmciHost *emmc = new_dwmci_host(0x12200000, 100000000, 8, 0,
DWMCI_SET_SAMPLE_CLK(1) |
DWMCI_SET_DRV_CLK(3) |
DWMCI_SET_DIV_RATIO(3));
- DwmciHost *sd_card = new_dwmci_host((void *)(uintptr_t)0x12220000,
- 100000000, 4, 1,
+ DwmciHost *sd_card = new_dwmci_host(0x12220000, 100000000, 4, 1,
DWMCI_SET_SAMPLE_CLK(1) |
DWMCI_SET_DRV_CLK(2) |
DWMCI_SET_DIV_RATIO(3));
@@ -97,10 +94,8 @@ static int board_setup(void)
if (power_set_ops(&exynos_power_ops))
return 1;
- UsbHostController *usb_drd0 = new_usb_hc(XHCI,
- (void *)(uintptr_t)0x12000000);
- UsbHostController *usb_drd1 = new_usb_hc(XHCI,
- (void *)(uintptr_t)0x12400000);
+ UsbHostController *usb_drd0 = new_usb_hc(XHCI, 0x12000000);
+ UsbHostController *usb_drd1 = new_usb_hc(XHCI, 0x12400000);
if (!usb_drd0 || !usb_drd1)
return 1;
diff --git a/src/drivers/bus/i2c/exynos5_usi.c b/src/drivers/bus/i2c/exynos5_usi.c
index eeed396..2a7c9ab 100644
--- a/src/drivers/bus/i2c/exynos5_usi.c
+++ b/src/drivers/bus/i2c/exynos5_usi.c
@@ -374,7 +374,7 @@ static int exynos5_usi_i2c_read(I2cOps *me, uint8_t chip,
return 0;
}
-Exynos5UsiI2c *new_exynos5_usi_i2c(void *reg_addr, unsigned frequency)
+Exynos5UsiI2c *new_exynos5_usi_i2c(uintptr_t reg_addr, unsigned frequency)
{
Exynos5UsiI2c *bus = malloc(sizeof(*bus));
if (!bus) {
@@ -385,7 +385,7 @@ Exynos5UsiI2c *new_exynos5_usi_i2c(void *reg_addr, unsigned frequency)
bus->ops.read = &exynos5_usi_i2c_read;
bus->ops.write = &exynos5_usi_i2c_write;
- bus->reg_addr = reg_addr;
+ bus->reg_addr = (void *)reg_addr;
bus->frequency = frequency;
return bus;
}
diff --git a/src/drivers/bus/i2c/exynos5_usi.h b/src/drivers/bus/i2c/exynos5_usi.h
index b1e7313..91fcf0f 100644
--- a/src/drivers/bus/i2c/exynos5_usi.h
+++ b/src/drivers/bus/i2c/exynos5_usi.h
@@ -30,6 +30,6 @@ typedef struct Exynos5UsiI2c
int ready;
} Exynos5UsiI2c;
-Exynos5UsiI2c *new_exynos5_usi_i2c(void *reg_addr, unsigned frequency);
+Exynos5UsiI2c *new_exynos5_usi_i2c(uintptr_t reg_addr, unsigned frequency);
#endif /* __DRIVERS_BUS_I2C_EXYNOS5_USI_H__ */
diff --git a/src/drivers/bus/i2c/s3c24x0.c b/src/drivers/bus/i2c/s3c24x0.c
index eda2278..249bdf0 100644
--- a/src/drivers/bus/i2c/s3c24x0.c
+++ b/src/drivers/bus/i2c/s3c24x0.c
@@ -250,7 +250,7 @@ static int i2c_write(I2cOps *me, uint8_t chip, uint32_t addr, int addr_len,
return i2c_send_stop(regs) || res;
}
-S3c24x0I2c *new_s3c24x0_i2c(void *reg_addr)
+S3c24x0I2c *new_s3c24x0_i2c(uintptr_t reg_addr)
{
S3c24x0I2c *bus = malloc(sizeof(*bus));
if (!bus)
@@ -259,6 +259,6 @@ S3c24x0I2c *new_s3c24x0_i2c(void *reg_addr)
bus->ops.read = &i2c_read;
bus->ops.write = &i2c_write;
- bus->reg_addr = reg_addr;
+ bus->reg_addr = (void *)reg_addr;
return bus;
}
diff --git a/src/drivers/bus/i2c/s3c24x0.h b/src/drivers/bus/i2c/s3c24x0.h
index 362896a..80ac76f 100644
--- a/src/drivers/bus/i2c/s3c24x0.h
+++ b/src/drivers/bus/i2c/s3c24x0.h
@@ -29,6 +29,6 @@ typedef struct S3c24x0I2c
int ready;
} S3c24x0I2c;
-S3c24x0I2c *new_s3c24x0_i2c(void *reg_addr);
+S3c24x0I2c *new_s3c24x0_i2c(uintptr_t reg_addr);
#endif /* __DRIVERS_BUS_I2C_S3C24X0_H__ */
diff --git a/src/drivers/bus/i2s/exynos5.c b/src/drivers/bus/i2s/exynos5.c
index 6ec6c70..59b4d57 100644
--- a/src/drivers/bus/i2s/exynos5.c
+++ b/src/drivers/bus/i2s/exynos5.c
@@ -200,7 +200,7 @@ static int i2s_send(I2sOps *me, uint32_t *data, unsigned int length)
return 0;
}
-Exynos5I2s *new_exynos5_i2s(void *regs, int bits_per_sample,
+Exynos5I2s *new_exynos5_i2s(uintptr_t regs, int bits_per_sample,
int channels, int lr_frame_size)
{
Exynos5I2s *bus = malloc(sizeof(*bus));
@@ -210,7 +210,7 @@ Exynos5I2s *new_exynos5_i2s(void *regs, int bits_per_sample,
}
memset(bus, 0, sizeof(*bus));
bus->ops.send = &i2s_send;
- bus->regs = regs;
+ bus->regs = (void *)regs;
bus->bits_per_sample = bits_per_sample;
bus->channels = channels;
bus->lr_frame_size = lr_frame_size;
@@ -319,7 +319,7 @@ static int i2s_send_multi(I2sOps *me, uint32_t *data, unsigned int length)
return 0;
}
-Exynos5I2s *new_exynos5_i2s_multi(void *regs, int bits_per_sample,
+Exynos5I2s *new_exynos5_i2s_multi(uintptr_t regs, int bits_per_sample,
int channels, int lr_frame_size)
{
Exynos5I2s *bus = malloc(sizeof(*bus));
@@ -329,7 +329,7 @@ Exynos5I2s *new_exynos5_i2s_multi(void *regs, int bits_per_sample,
}
memset(bus, 0, sizeof(*bus));
bus->ops.send = &i2s_send_multi;
- bus->regs = regs;
+ bus->regs = (void *)regs;
bus->bits_per_sample = bits_per_sample;
bus->channels = channels;
bus->lr_frame_size = lr_frame_size;
diff --git a/src/drivers/bus/i2s/exynos5.h b/src/drivers/bus/i2s/exynos5.h
index 4bb2a97..b9fc874 100644
--- a/src/drivers/bus/i2s/exynos5.h
+++ b/src/drivers/bus/i2s/exynos5.h
@@ -35,10 +35,10 @@ typedef struct
int lr_frame_size;
} Exynos5I2s;
-Exynos5I2s *new_exynos5_i2s(void *regs, int bits_per_sample,
+Exynos5I2s *new_exynos5_i2s(uintptr_t regs, int bits_per_sample,
int channels, int lr_frame_size);
-Exynos5I2s *new_exynos5_i2s_multi(void *regs, int bits_per_sample,
+Exynos5I2s *new_exynos5_i2s_multi(uintptr_t regs, int bits_per_sample,
int channels, int lr_frame_size);
#endif /* __DRIVERS_BUS_I2S_EXYNOS5_H__ */
diff --git a/src/drivers/bus/spi/exynos5.c b/src/drivers/bus/spi/exynos5.c
index 2423f89..c7a945a 100644
--- a/src/drivers/bus/spi/exynos5.c
+++ b/src/drivers/bus/spi/exynos5.c
@@ -273,7 +273,7 @@ static int exynos5_spi_stop(SpiOps *me)
return 0;
}
-Exynos5Spi *new_exynos5_spi(void *reg_addr)
+Exynos5Spi *new_exynos5_spi(uintptr_t reg_addr)
{
Exynos5Spi *bus = malloc(sizeof(*bus));
if (!bus) {
@@ -284,6 +284,6 @@ Exynos5Spi *new_exynos5_spi(void *reg_addr)
bus->ops.start = &exynos5_spi_start;
bus->ops.transfer = &exynos5_spi_transfer;
bus->ops.stop = &exynos5_spi_stop;
- bus->reg_addr = reg_addr;
+ bus->reg_addr = (void *)reg_addr;
return bus;
}
diff --git a/src/drivers/bus/spi/exynos5.h b/src/drivers/bus/spi/exynos5.h
index ea2bf17..f8bac57 100644
--- a/src/drivers/bus/spi/exynos5.h
+++ b/src/drivers/bus/spi/exynos5.h
@@ -30,6 +30,6 @@ typedef struct Exynos5Spi
int started;
} Exynos5Spi;
-Exynos5Spi *new_exynos5_spi(void *reg_addr);
+Exynos5Spi *new_exynos5_spi(uintptr_t reg_addr);
#endif /* __DRIVERS_BUS_SPI_EXYNOS5_H__ */
diff --git a/src/drivers/bus/usb/usb.c b/src/drivers/bus/usb/usb.c
index 6be0ae2..cd0a7ba 100644
--- a/src/drivers/bus/usb/usb.c
+++ b/src/drivers/bus/usb/usb.c
@@ -66,7 +66,7 @@ void usb_generic_remove(usbdev_t *dev)
dev->data = NULL;
}
-UsbHostController *new_usb_hc(hc_type type, void *bar)
+UsbHostController *new_usb_hc(hc_type type, uintptr_t bar)
{
UsbHostController *hc = malloc(sizeof(*hc));
if (!hc) {
diff --git a/src/drivers/bus/usb/usb.h b/src/drivers/bus/usb/usb.h
index 9994c3c..b0f795e 100644
--- a/src/drivers/bus/usb/usb.h
+++ b/src/drivers/bus/usb/usb.h
@@ -53,7 +53,7 @@ typedef struct {
extern ListNode usb_host_controllers;
-UsbHostController *new_usb_hc(hc_type type, void *bar);
+UsbHostController *new_usb_hc(hc_type type, uintptr_t bar);
void dc_usb_initialize(void);
#endif /* __DRIVERS_BUS_USB_USB_H__ */
diff --git a/src/drivers/storage/dw_mmc.c b/src/drivers/storage/dw_mmc.c
index f7df8de..7393f22 100644
--- a/src/drivers/storage/dw_mmc.c
+++ b/src/drivers/storage/dw_mmc.c
@@ -396,7 +396,7 @@ static int dwmci_update(BlockDevCtrlrOps *me)
return 0;
}
-DwmciHost *new_dwmci_host(void *ioaddr, uint32_t src_hz, int bus_width,
+DwmciHost *new_dwmci_host(uintptr_t ioaddr, uint32_t src_hz, int bus_width,
int removable, uint32_t clksel_val)
{
DwmciHost *ctrlr = malloc(sizeof(*ctrlr));
@@ -426,7 +426,7 @@ DwmciHost *new_dwmci_host(void *ioaddr, uint32_t src_hz, int bus_width,
ctrlr->mmc.send_cmd = &dwmci_send_cmd;
ctrlr->mmc.set_ios = &dwmci_set_ios;
- ctrlr->ioaddr = ioaddr;
+ ctrlr->ioaddr = (void *)ioaddr;
ctrlr->src_hz = src_hz;
ctrlr->clksel_val = clksel_val;
ctrlr->removable = removable;
diff --git a/src/drivers/storage/dw_mmc.h b/src/drivers/storage/dw_mmc.h
index 450a863..f7b749d 100644
--- a/src/drivers/storage/dw_mmc.h
+++ b/src/drivers/storage/dw_mmc.h
@@ -212,6 +212,6 @@ static inline void *dwmci_get_ioaddr(DwmciHost *host, int reg)
return (void *)((uint8_t *)host->ioaddr + reg);
}
-DwmciHost *new_dwmci_host(void *ioaddr, uint32_t src_hz, int bus_width,
+DwmciHost *new_dwmci_host(uintptr_t ioaddr, uint32_t src_hz, int bus_width,
int removable, uint32_t clksel_val);
#endif /* __DRIVERS_STORAGE_DW_MMC_H__ */
diff --git a/src/drivers/storage/exynos_mshc.h b/src/drivers/storage/exynos_mshc.h
index cfcf2cd..d7675f3 100644
--- a/src/drivers/storage/exynos_mshc.h
+++ b/src/drivers/storage/exynos_mshc.h
@@ -177,7 +177,7 @@ typedef struct MshciHost {
int removable;
} MshciHost;
-MshciHost *new_mshci_host(void *ioaddr, uint32_t src_hz, int bus_width,
+MshciHost *new_mshci_host(uintptr_t ioaddr, uint32_t src_hz, int bus_width,
int removable, uint32_t clksel_val);
#endif /* __DRIVERS_STORAGE_EXYNOS_MSHC_H__ */
diff --git a/src/drivers/storage/s5p_mshc.c b/src/drivers/storage/s5p_mshc.c
index bc5f4ae..3e4cbca 100644
--- a/src/drivers/storage/s5p_mshc.c
+++ b/src/drivers/storage/s5p_mshc.c
@@ -517,7 +517,7 @@ static int s5p_mshc_update(BlockDevCtrlrOps *me)
return 0;
}
-MshciHost *new_mshci_host(void *ioaddr, uint32_t src_hz, int bus_width,
+MshciHost *new_mshci_host(uintptr_t ioaddr, uint32_t src_hz, int bus_width,
int removable, uint32_t clksel_val)
{
MshciHost *ctrlr = malloc(sizeof(*ctrlr));
@@ -547,7 +547,7 @@ MshciHost *new_mshci_host(void *ioaddr, uint32_t src_hz, int bus_width,
ctrlr->mmc.send_cmd = &s5p_mshci_send_command;
ctrlr->mmc.set_ios = &s5p_mshci_set_ios;
- ctrlr->regs = ioaddr;
+ ctrlr->regs = (void *)ioaddr;
ctrlr->src_hz = src_hz;
ctrlr->clksel_val = clksel_val;
ctrlr->removable = removable;