diff --git a/pinctrl/gpiochip_bcm2712.c b/pinctrl/gpiochip_bcm2712.c index 4c65470..165136e 100644 --- a/pinctrl/gpiochip_bcm2712.c +++ b/pinctrl/gpiochip_bcm2712.c @@ -41,7 +41,7 @@ struct bcm2712_inst }; static unsigned num_instances; -static struct bcm2712_inst bcm2712_instances[BCM2712_MAX_INSTANCES] = { 0 }; +static struct bcm2712_inst bcm2712_instances[BCM2712_MAX_INSTANCES] = { {0,0,0,0,0,0,0} }; static unsigned shared_flags; static const char *bcm2712_c0_gpio_alt_names[][BCM2712_FSEL_COUNT - 1] = @@ -328,7 +328,7 @@ static volatile uint32_t *bcm2712_pad_base(struct bcm2712_inst *inst, static int bcm2712_gpio_get_level(void *priv, unsigned gpio) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int bit; volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit); @@ -340,7 +340,7 @@ static int bcm2712_gpio_get_level(void *priv, unsigned gpio) static void bcm2712_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int bit; volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit); uint32_t gpio_val; @@ -355,7 +355,7 @@ static void bcm2712_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv) static GPIO_DRIVE_T bcm2712_gpio_get_drive(void *priv, unsigned gpio) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int bit; volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit); uint32_t gpio_val; @@ -369,7 +369,7 @@ static GPIO_DRIVE_T bcm2712_gpio_get_drive(void *priv, unsigned gpio) static void bcm2712_gpio_set_dir(void *priv, unsigned gpio, GPIO_DIR_T dir) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int bit; volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit); uint32_t gpio_val; @@ -385,7 +385,7 @@ static void bcm2712_gpio_set_dir(void *priv, unsigned gpio, GPIO_DIR_T dir) static GPIO_DIR_T bcm2712_gpio_get_dir(void *priv, unsigned gpio) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int bit; volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit); uint32_t gpio_val; @@ -399,30 +399,30 @@ static GPIO_DIR_T bcm2712_gpio_get_dir(void *priv, unsigned gpio) static GPIO_FSEL_T bcm2712_pinctrl_get_fsel(void *priv, unsigned gpio) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int pinmux_bit; volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit); int fsel; if (!pinmux_base) - return -1; + return (GPIO_FSEL_T)-1; fsel = ((*pinmux_base >> pinmux_bit) & 0xf); if (fsel == 0) return GPIO_FSEL_GPIO; else if (fsel < BCM2712_FSEL_COUNT) - return GPIO_FSEL_FUNC1 + (fsel - 1); + return (GPIO_FSEL_T)(GPIO_FSEL_FUNC1 + (fsel - 1)); else if (fsel == 0xf) // Choose one value as a considered NONE return GPIO_FSEL_NONE; /* Unknown FSEL */ - return -1; + return (GPIO_FSEL_T)-1; } static void bcm2712_pinctrl_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int pinmux_bit; volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit); uint32_t pinmux_val; @@ -458,7 +458,7 @@ static void bcm2712_pinctrl_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_ static GPIO_PULL_T bcm2712_pinctrl_get_pull(void *priv, unsigned gpio) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int bit; volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit); uint32_t pad_val; @@ -482,7 +482,7 @@ static GPIO_PULL_T bcm2712_pinctrl_get_pull(void *priv, unsigned gpio) static void bcm2712_pinctrl_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned int bit = 0; volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit); uint32_t padval; @@ -589,14 +589,14 @@ static void *bcm2712_gpio_create_instance(const GPIO_CHIP_T *chip, static int bcm2712_gpio_count(void *priv) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; return inst->num_gpios; } static void *bcm2712_gpio_probe_instance(void *priv, volatile uint32_t *base) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; inst->gpio_base = base; @@ -672,7 +672,7 @@ static void *bcm2712_pinctrl_create_instance(const GPIO_CHIP_T *chip, static int bcm2712_pinctrl_count(void *priv) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; if (inst->flags & FLAGS_GPIO) return 0; /* Don't occupy any GPIO space */ @@ -702,7 +702,7 @@ static int bcm2712_pinctrl_count(void *priv) static void *bcm2712_pinctrl_probe_instance(void *priv, volatile uint32_t *base) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; unsigned pad_offset; inst->pinmux_base = base; @@ -731,7 +731,7 @@ static void *bcm2712_pinctrl_probe_instance(void *priv, volatile uint32_t *base) static const char *bcm2712_pinctrl_get_fsel_name(void *priv, unsigned gpio, GPIO_FSEL_T fsel) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; const char *name = NULL; switch (fsel) @@ -788,7 +788,7 @@ static const char *bcm2712_pinctrl_get_fsel_name(void *priv, unsigned gpio, GPIO static const char *bcm2712_gpio_get_name(void *priv, unsigned gpio) { - struct bcm2712_inst *inst = priv; + struct bcm2712_inst *inst = (struct bcm2712_inst*)priv; const char *fsel_name; static char name_buf[16]; unsigned gpio_offset; diff --git a/pinctrl/gpiochip_bcm2835.c b/pinctrl/gpiochip_bcm2835.c index 1befc01..626f480 100644 --- a/pinctrl/gpiochip_bcm2835.c +++ b/pinctrl/gpiochip_bcm2835.c @@ -157,7 +157,7 @@ static const char *bcm2711_gpio_alt_names[BCM2711_NUM_GPIOS][BCM2711_ALT_COUNT] static GPIO_FSEL_T bcm2835_gpio_get_fsel(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; /* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */ uint32_t reg = GPFSEL0 + (gpio / 10); uint32_t lsb = (gpio % 10) * 3; @@ -182,7 +182,7 @@ static GPIO_FSEL_T bcm2835_gpio_get_fsel(void *priv, unsigned gpio) static void bcm2835_gpio_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; /* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */ uint32_t reg = GPFSEL0 + (gpio / 10); uint32_t lsb = (gpio % 10) * 3; @@ -232,7 +232,7 @@ static void bcm2835_gpio_set_dir(void *priv, unsigned gpio, GPIO_DIR_T dir) static int bcm2835_gpio_get_level(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; if (gpio >= BCM2835_NUM_GPIOS) return -1; @@ -250,7 +250,7 @@ GPIO_DRIVE_T bcm2835_gpio_get_drive(void *priv, unsigned gpio) static void bcm2835_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; if (gpio < BCM2835_NUM_GPIOS && drv <= DRIVE_HIGH) base[(drv ? GPSET0 : GPCLR0) + (gpio / 32)] = (1 << (gpio % 32)); @@ -266,7 +266,7 @@ static GPIO_PULL_T bcm2835_gpio_get_pull(void *priv, unsigned gpio) static void bcm2835_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int clkreg = GPPUDCLK0 + (gpio / 32); int clkbit = 1 << (gpio % 32); @@ -324,7 +324,7 @@ static const char *bcm2835_gpio_get_fsel_name(void *priv, unsigned gpio, GPIO_FS static GPIO_PULL_T bcm2711_gpio_get_pull(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int reg = GPPUPPDN0 + (gpio / 16); int lsb = (gpio % 16) * 2; @@ -343,7 +343,7 @@ static GPIO_PULL_T bcm2711_gpio_get_pull(void *priv, unsigned gpio) static void bcm2711_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int reg = GPPUPPDN0 + (gpio / 16); int lsb = (gpio % 16) * 2; int pull_val; diff --git a/pinctrl/gpiochip_rp1.c b/pinctrl/gpiochip_rp1.c index 7bb0003..b5b5f46 100644 --- a/pinctrl/gpiochip_rp1.c +++ b/pinctrl/gpiochip_rp1.c @@ -228,7 +228,7 @@ static void rp1_gpio_sys_rio_oe_set(volatile uint32_t *base, int bank, int offse static void rp1_gpio_set_dir(void *priv, uint32_t gpio, GPIO_DIR_T dir) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int bank, offset; rp1_gpio_get_bank(gpio, &bank, &offset); @@ -243,7 +243,7 @@ static void rp1_gpio_set_dir(void *priv, uint32_t gpio, GPIO_DIR_T dir) static GPIO_DIR_T rp1_gpio_get_dir(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int bank, offset; GPIO_DIR_T dir; uint32_t reg; @@ -258,7 +258,7 @@ static GPIO_DIR_T rp1_gpio_get_dir(void *priv, unsigned gpio) static GPIO_FSEL_T rp1_gpio_get_fsel(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int bank, offset; uint32_t reg; GPIO_FSEL_T fsel; @@ -266,7 +266,7 @@ static GPIO_FSEL_T rp1_gpio_get_fsel(void *priv, unsigned gpio) rp1_gpio_get_bank(gpio, &bank, &offset); reg = rp1_gpio_ctrl_read(base, bank, offset); - rsel = ((reg & RP1_GPIO_CTRL_FSEL_MASK) >> RP1_GPIO_CTRL_FSEL_LSB); + rsel = (RP1_FSEL_T)((reg & RP1_GPIO_CTRL_FSEL_MASK) >> RP1_GPIO_CTRL_FSEL_LSB); if (rsel == RP1_FSEL_SYS_RIO) fsel = GPIO_FSEL_GPIO; else if (rsel == RP1_FSEL_NULL) @@ -281,7 +281,7 @@ static GPIO_FSEL_T rp1_gpio_get_fsel(void *priv, unsigned gpio) static void rp1_gpio_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int bank, offset; uint32_t ctrl_reg; uint32_t pad_reg; @@ -339,7 +339,7 @@ static void rp1_gpio_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func) static int rp1_gpio_get_level(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int bank, offset; uint32_t pad_reg; uint32_t reg; @@ -357,7 +357,7 @@ static int rp1_gpio_get_level(void *priv, unsigned gpio) static void rp1_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; int bank, offset; rp1_gpio_get_bank(gpio, &bank, &offset); @@ -369,7 +369,7 @@ static void rp1_gpio_set_drive(void *priv, unsigned gpio, GPIO_DRIVE_T drv) static void rp1_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; uint32_t reg; int bank, offset; @@ -385,7 +385,7 @@ static void rp1_gpio_set_pull(void *priv, unsigned gpio, GPIO_PULL_T pull) static GPIO_PULL_T rp1_gpio_get_pull(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; uint32_t reg; GPIO_PULL_T pull = PULL_NONE; int bank, offset; @@ -402,7 +402,7 @@ static GPIO_PULL_T rp1_gpio_get_pull(void *priv, unsigned gpio) static GPIO_DRIVE_T rp1_gpio_get_drive(void *priv, unsigned gpio) { - volatile uint32_t *base = priv; + volatile uint32_t *base = (volatile uint32_t*)priv; uint32_t reg; int bank, offset; diff --git a/pinctrl/util.c b/pinctrl/util.c index ff9fc95..19cdd4e 100644 --- a/pinctrl/util.c +++ b/pinctrl/util.c @@ -46,7 +46,7 @@ static void *do_read_file(const char *fname, const char *mode, size_t *plen) char *read_text_file(const char *fname, size_t *plen) { - return do_read_file(fname, "rt", plen); + return (char*)do_read_file(fname, "rt", plen); } void *read_file(const char *fname, size_t *plen) @@ -73,7 +73,7 @@ char *dt_read_prop(const char *node, const char *prop, size_t *plen) filename[sizeof(filename) - 1] = '\0'; - return read_file(filename, plen); + return (char*)read_file(filename, plen); } uint32_t *dt_read_cells(const char *node, const char *prop, unsigned *num_cells)