icE1usb fw/misc: Add support for GPIO special function
Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: If694fc94fd0bdedc87f00fbf1e13eb517fed67f6
This commit is contained in:
parent
5398910555
commit
f5e51f5d9f
|
@ -15,10 +15,14 @@
|
||||||
|
|
||||||
struct misc {
|
struct misc {
|
||||||
uint32_t warmboot;
|
uint32_t warmboot;
|
||||||
struct {
|
union {
|
||||||
uint16_t oe_out;
|
struct {
|
||||||
uint8_t in;
|
uint8_t out;
|
||||||
uint8_t _rsvd;
|
uint8_t oe;
|
||||||
|
uint8_t in;
|
||||||
|
uint8_t sfn;
|
||||||
|
};
|
||||||
|
uint32_t reg;
|
||||||
} gpio;
|
} gpio;
|
||||||
uint32_t e1_led;
|
uint32_t e1_led;
|
||||||
uint32_t _rsvd;
|
uint32_t _rsvd;
|
||||||
|
@ -50,26 +54,37 @@ pdm_set(int chan, bool enable, unsigned value, bool normalize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gpio_sfn(int n, bool sfn)
|
||||||
|
{
|
||||||
|
uint32_t mask = 0x01000000 << n;
|
||||||
|
|
||||||
|
if (sfn)
|
||||||
|
misc_regs->gpio.reg |= mask;
|
||||||
|
else
|
||||||
|
misc_regs->gpio.reg &= ~mask;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gpio_dir(int n, bool output)
|
gpio_dir(int n, bool output)
|
||||||
{
|
{
|
||||||
uint16_t mask = 256 << n;
|
uint32_t mask = 0x00000100 << n;
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
misc_regs->gpio.oe_out |= mask;
|
misc_regs->gpio.reg |= mask;
|
||||||
else
|
else
|
||||||
misc_regs->gpio.oe_out &= ~mask;
|
misc_regs->gpio.reg &= ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gpio_out(int n, bool val)
|
gpio_out(int n, bool val)
|
||||||
{
|
{
|
||||||
uint16_t mask = 1 << n;
|
uint32_t mask = 0x00000001 << n;
|
||||||
|
|
||||||
if (val)
|
if (val)
|
||||||
misc_regs->gpio.oe_out |= mask;
|
misc_regs->gpio.reg |= mask;
|
||||||
else
|
else
|
||||||
misc_regs->gpio.oe_out &= ~mask;
|
misc_regs->gpio.reg &= ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -26,6 +26,7 @@ enum pdm_chan {
|
||||||
|
|
||||||
void pdm_set(int chan, bool enable, unsigned value, bool normalize);
|
void pdm_set(int chan, bool enable, unsigned value, bool normalize);
|
||||||
|
|
||||||
|
void gpio_sfn(int n, bool sfn);
|
||||||
void gpio_dir(int n, bool output);
|
void gpio_dir(int n, bool output);
|
||||||
void gpio_out(int n, bool val);
|
void gpio_out(int n, bool val);
|
||||||
bool gpio_in(int n);
|
bool gpio_in(int n);
|
||||||
|
|
Loading…
Reference in New Issue