mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-25 05:32:20 +00:00
changed pinctrl to *.cpp
This commit is contained in:
parent
e1bf397515
commit
1682e0019f
@ -41,7 +41,7 @@ struct bcm2712_inst
|
|||||||
};
|
};
|
||||||
|
|
||||||
static unsigned num_instances;
|
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 unsigned shared_flags;
|
||||||
|
|
||||||
static const char *bcm2712_c0_gpio_alt_names[][BCM2712_FSEL_COUNT - 1] =
|
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)
|
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;
|
unsigned int bit;
|
||||||
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &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)
|
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;
|
unsigned int bit;
|
||||||
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
||||||
uint32_t gpio_val;
|
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)
|
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;
|
unsigned int bit;
|
||||||
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
||||||
uint32_t gpio_val;
|
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)
|
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;
|
unsigned int bit;
|
||||||
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
||||||
uint32_t gpio_val;
|
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)
|
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;
|
unsigned int bit;
|
||||||
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
volatile uint32_t *gpio_base = bcm2712_gpio_base(inst, gpio, &bit);
|
||||||
uint32_t gpio_val;
|
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)
|
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;
|
unsigned int pinmux_bit;
|
||||||
volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit);
|
volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit);
|
||||||
int fsel;
|
int fsel;
|
||||||
|
|
||||||
if (!pinmux_base)
|
if (!pinmux_base)
|
||||||
return -1;
|
return (GPIO_FSEL_T)-1;
|
||||||
|
|
||||||
fsel = ((*pinmux_base >> pinmux_bit) & 0xf);
|
fsel = ((*pinmux_base >> pinmux_bit) & 0xf);
|
||||||
|
|
||||||
if (fsel == 0)
|
if (fsel == 0)
|
||||||
return GPIO_FSEL_GPIO;
|
return GPIO_FSEL_GPIO;
|
||||||
else if (fsel < BCM2712_FSEL_COUNT)
|
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
|
else if (fsel == 0xf) // Choose one value as a considered NONE
|
||||||
return GPIO_FSEL_NONE;
|
return GPIO_FSEL_NONE;
|
||||||
|
|
||||||
/* Unknown FSEL */
|
/* Unknown FSEL */
|
||||||
return -1;
|
return (GPIO_FSEL_T)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bcm2712_pinctrl_set_fsel(void *priv, unsigned gpio, const GPIO_FSEL_T func)
|
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;
|
unsigned int pinmux_bit;
|
||||||
volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit);
|
volatile uint32_t *pinmux_base = bcm2712_pinmux_base(inst, gpio, &pinmux_bit);
|
||||||
uint32_t pinmux_val;
|
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)
|
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;
|
unsigned int bit;
|
||||||
volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit);
|
volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit);
|
||||||
uint32_t pad_val;
|
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)
|
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;
|
unsigned int bit = 0;
|
||||||
volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit);
|
volatile uint32_t *pad_base = bcm2712_pad_base(inst, gpio, &bit);
|
||||||
uint32_t padval;
|
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)
|
static int bcm2712_gpio_count(void *priv)
|
||||||
{
|
{
|
||||||
struct bcm2712_inst *inst = priv;
|
struct bcm2712_inst *inst = (struct bcm2712_inst*)priv;
|
||||||
|
|
||||||
return inst->num_gpios;
|
return inst->num_gpios;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *bcm2712_gpio_probe_instance(void *priv, volatile uint32_t *base)
|
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;
|
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)
|
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)
|
if (inst->flags & FLAGS_GPIO)
|
||||||
return 0; /* Don't occupy any GPIO space */
|
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)
|
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;
|
unsigned pad_offset;
|
||||||
|
|
||||||
inst->pinmux_base = base;
|
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)
|
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;
|
const char *name = NULL;
|
||||||
|
|
||||||
switch (fsel)
|
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)
|
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;
|
const char *fsel_name;
|
||||||
static char name_buf[16];
|
static char name_buf[16];
|
||||||
unsigned gpio_offset;
|
unsigned gpio_offset;
|
@ -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)
|
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) */
|
/* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */
|
||||||
uint32_t reg = GPFSEL0 + (gpio / 10);
|
uint32_t reg = GPFSEL0 + (gpio / 10);
|
||||||
uint32_t lsb = (gpio % 10) * 3;
|
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)
|
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) */
|
/* GPFSEL0-5 with 10 sels per reg, 3 bits per sel (so bits 0:29 used) */
|
||||||
uint32_t reg = GPFSEL0 + (gpio / 10);
|
uint32_t reg = GPFSEL0 + (gpio / 10);
|
||||||
uint32_t lsb = (gpio % 10) * 3;
|
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)
|
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)
|
if (gpio >= BCM2835_NUM_GPIOS)
|
||||||
return -1;
|
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)
|
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)
|
if (gpio < BCM2835_NUM_GPIOS && drv <= DRIVE_HIGH)
|
||||||
base[(drv ? GPSET0 : GPCLR0) + (gpio / 32)] = (1 << (gpio % 32));
|
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)
|
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 clkreg = GPPUDCLK0 + (gpio / 32);
|
||||||
int clkbit = 1 << (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)
|
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 reg = GPPUPPDN0 + (gpio / 16);
|
||||||
int lsb = (gpio % 16) * 2;
|
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)
|
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 reg = GPPUPPDN0 + (gpio / 16);
|
||||||
int lsb = (gpio % 16) * 2;
|
int lsb = (gpio % 16) * 2;
|
||||||
int pull_val;
|
int pull_val;
|
@ -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)
|
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;
|
int bank, offset;
|
||||||
|
|
||||||
rp1_gpio_get_bank(gpio, &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)
|
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;
|
int bank, offset;
|
||||||
GPIO_DIR_T dir;
|
GPIO_DIR_T dir;
|
||||||
uint32_t reg;
|
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)
|
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;
|
int bank, offset;
|
||||||
uint32_t reg;
|
uint32_t reg;
|
||||||
GPIO_FSEL_T fsel;
|
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);
|
rp1_gpio_get_bank(gpio, &bank, &offset);
|
||||||
reg = rp1_gpio_ctrl_read(base, 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)
|
if (rsel == RP1_FSEL_SYS_RIO)
|
||||||
fsel = GPIO_FSEL_GPIO;
|
fsel = GPIO_FSEL_GPIO;
|
||||||
else if (rsel == RP1_FSEL_NULL)
|
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)
|
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;
|
int bank, offset;
|
||||||
uint32_t ctrl_reg;
|
uint32_t ctrl_reg;
|
||||||
uint32_t pad_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)
|
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;
|
int bank, offset;
|
||||||
uint32_t pad_reg;
|
uint32_t pad_reg;
|
||||||
uint32_t 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)
|
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;
|
int bank, offset;
|
||||||
|
|
||||||
rp1_gpio_get_bank(gpio, &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)
|
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;
|
uint32_t reg;
|
||||||
int bank, offset;
|
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)
|
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;
|
uint32_t reg;
|
||||||
GPIO_PULL_T pull = PULL_NONE;
|
GPIO_PULL_T pull = PULL_NONE;
|
||||||
int bank, offset;
|
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)
|
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;
|
uint32_t reg;
|
||||||
int bank, offset;
|
int bank, offset;
|
||||||
|
|
@ -174,7 +174,7 @@ void gpio_set(unsigned gpio)
|
|||||||
|
|
||||||
if (gpio_get_interface(gpio, &iface, &priv, &gpio_offset) == 0)
|
if (gpio_get_interface(gpio, &iface, &priv, &gpio_offset) == 0)
|
||||||
{
|
{
|
||||||
iface->gpio_set_drive(priv, gpio_offset, 1);
|
iface->gpio_set_drive(priv, gpio_offset, DRIVE_HIGH);
|
||||||
iface->gpio_set_dir(priv, gpio_offset, DIR_OUTPUT);
|
iface->gpio_set_dir(priv, gpio_offset, DIR_OUTPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ void gpio_clear(unsigned gpio)
|
|||||||
|
|
||||||
if (gpio_get_interface(gpio, &iface, &priv, &gpio_offset) == 0)
|
if (gpio_get_interface(gpio, &iface, &priv, &gpio_offset) == 0)
|
||||||
{
|
{
|
||||||
iface->gpio_set_drive(priv, gpio_offset, 0);
|
iface->gpio_set_drive(priv, gpio_offset, DRIVE_LOW);
|
||||||
iface->gpio_set_dir(priv, gpio_offset, DIR_OUTPUT);
|
iface->gpio_set_dir(priv, gpio_offset, DIR_OUTPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -692,7 +692,7 @@ int gpiolib_mmap(void)
|
|||||||
return errno;
|
return errno;
|
||||||
|
|
||||||
new_priv = chip->interface->gpio_probe_instance(inst->priv,
|
new_priv = chip->interface->gpio_probe_instance(inst->priv,
|
||||||
(void *)((char *)gpio_map + align));
|
(uint32_t *)((char *)gpio_map + align));
|
||||||
if (!new_priv)
|
if (!new_priv)
|
||||||
return -1;
|
return -1;
|
||||||
inst->priv = new_priv;
|
inst->priv = new_priv;
|
@ -1,4 +1,6 @@
|
|||||||
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -48,7 +50,7 @@ static void print_gpio_alts_info(unsigned gpio)
|
|||||||
printf(", %s", name);
|
printf(", %s", name);
|
||||||
for (fsel = GPIO_FSEL_FUNC0; ; fsel++)
|
for (fsel = GPIO_FSEL_FUNC0; ; fsel++)
|
||||||
{
|
{
|
||||||
name = gpio_get_gpio_fsel_name(gpio, fsel);
|
name = gpio_get_gpio_fsel_name(gpio, (GPIO_FSEL_T)fsel);
|
||||||
if (!name)
|
if (!name)
|
||||||
break;
|
break;
|
||||||
printf(", %s", name);
|
printf(", %s", name);
|
||||||
@ -149,7 +151,7 @@ static int do_gpio_get(unsigned int gpio)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
fsel = gpio_get_fsel(gpio);
|
fsel = gpio_get_fsel(gpio);
|
||||||
printf("%2d: %2s ", num, gpio_get_fsel_name(fsel));
|
printf("%2d: %2s ", num, gpio_get_fsel_name((GPIO_FSEL_T)fsel));
|
||||||
if (fsel == GPIO_FSEL_OUTPUT)
|
if (fsel == GPIO_FSEL_OUTPUT)
|
||||||
printf("%s", gpio_get_drive_name(gpio_get_drive(gpio)));
|
printf("%s", gpio_get_drive_name(gpio_get_drive(gpio)));
|
||||||
else
|
else
|
||||||
@ -166,7 +168,7 @@ static int do_gpio_get(unsigned int gpio)
|
|||||||
(level == 1) ? "hi" : (level == 0) ? "lo" : "--",
|
(level == 1) ? "hi" : (level == 0) ? "lo" : "--",
|
||||||
name ? name : "",
|
name ? name : "",
|
||||||
name ? " = " : "",
|
name ? " = " : "",
|
||||||
gpio_get_gpio_fsel_name(gpio, fsel));
|
gpio_get_gpio_fsel_name(gpio, (GPIO_FSEL_T)fsel));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -189,7 +191,7 @@ static int do_gpio_set(unsigned int gpio, int fsparam, int drive, int pull)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (fsparam != GPIO_FSEL_MAX)
|
if (fsparam != GPIO_FSEL_MAX)
|
||||||
gpio_set_fsel(gpio, fsparam);
|
gpio_set_fsel(gpio, (GPIO_FSEL_T)fsparam);
|
||||||
else
|
else
|
||||||
fsparam = gpio_get_fsel(gpio);
|
fsparam = gpio_get_fsel(gpio);
|
||||||
|
|
||||||
@ -197,7 +199,7 @@ static int do_gpio_set(unsigned int gpio, int fsparam, int drive, int pull)
|
|||||||
{
|
{
|
||||||
if (fsparam == GPIO_FSEL_OUTPUT)
|
if (fsparam == GPIO_FSEL_OUTPUT)
|
||||||
{
|
{
|
||||||
gpio_set_drive(gpio, drive);
|
gpio_set_drive(gpio, (GPIO_DRIVE_T)drive);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -207,7 +209,7 @@ static int do_gpio_set(unsigned int gpio, int fsparam, int drive, int pull)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pull != PULL_MAX)
|
if (pull != PULL_MAX)
|
||||||
gpio_set_pull(gpio, pull);
|
gpio_set_pull(gpio, (GPIO_PULL_T)pull);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -265,7 +267,7 @@ static int do_gpio_poll_add(unsigned int gpio)
|
|||||||
if (!gpio_num_is_valid(gpio))
|
if (!gpio_num_is_valid(gpio))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
poll_gpios = reallocarray(poll_gpios, num_poll_gpios + 1,
|
poll_gpios = (struct poll_gpio_state*)reallocarray(poll_gpios, num_poll_gpios + 1,
|
||||||
sizeof(*poll_gpios));
|
sizeof(*poll_gpios));
|
||||||
new_gpio = &poll_gpios[num_poll_gpios];
|
new_gpio = &poll_gpios[num_poll_gpios];
|
||||||
new_gpio->num = num;
|
new_gpio->num = num;
|
||||||
@ -323,7 +325,7 @@ static void verbose_callback(const char *msg)
|
|||||||
{
|
{
|
||||||
printf("%s", msg);
|
printf("%s", msg);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -709,3 +711,4 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
@ -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)
|
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)
|
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';
|
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)
|
uint32_t *dt_read_cells(const char *node, const char *prop, unsigned *num_cells)
|
Loading…
Reference in New Issue
Block a user