summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/sunxi_gpio.c23
-rw-r--r--drivers/i2c/mvtwsi.c128
-rw-r--r--drivers/net/sunxi_emac.c2
-rw-r--r--drivers/power/axp152.c11
-rw-r--r--drivers/power/axp209.c46
-rw-r--r--drivers/power/axp221.c75
-rw-r--r--drivers/usb/musb-new/sunxi.c45
-rw-r--r--drivers/video/sunxi_display.c8
8 files changed, 185 insertions, 153 deletions
diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 62960929ad..510123fdf8 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -21,6 +21,9 @@
#ifdef CONFIG_AXP209_POWER
#include <axp209.h>
#endif
+#ifdef CONFIG_AXP221_POWER
+#include <axp221.h>
+#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -115,6 +118,20 @@ int gpio_set_value(unsigned gpio, int value)
return sunxi_gpio_output(gpio, value);
}
+int sunxi_name_to_gpio_bank(const char *name)
+{
+ int group = 0;
+
+ if (*name == 'P' || *name == 'p')
+ name++;
+ if (*name >= 'A') {
+ group = *name - (*name > 'a' ? 'a' : 'A');
+ return group;
+ }
+
+ return -1;
+}
+
int sunxi_name_to_gpio(const char *name)
{
int group = 0;
@@ -125,6 +142,12 @@ int sunxi_name_to_gpio(const char *name)
#ifdef AXP_GPIO
if (strncasecmp(name, "AXP0-", 5) == 0) {
name += 5;
+ if (strcmp(name, "VBUS-DETECT") == 0)
+ return SUNXI_GPIO_AXP0_START +
+ SUNXI_GPIO_AXP0_VBUS_DETECT;
+ if (strcmp(name, "VBUS-ENABLE") == 0)
+ return SUNXI_GPIO_AXP0_START +
+ SUNXI_GPIO_AXP0_VBUS_ENABLE;
pin = simple_strtol(name, &eptr, 10);
if (!*name || *eptr)
return -1;
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 6f6edd5e51..f20d1b2291 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -14,7 +14,7 @@
#include <asm/io.h>
/*
- * include a file that will provide CONFIG_I2C_MVTWSI_BASE
+ * include a file that will provide CONFIG_I2C_MVTWSI_BASE*
* and possibly other settings
*/
@@ -91,11 +91,39 @@ struct mvtwsi_registers {
#define MVTWSI_STATUS_IDLE 0xF8
/*
- * The single instance of the controller we'll be dealing with
+ * MVTWSI controller base
*/
-static struct mvtwsi_registers *twsi =
- (struct mvtwsi_registers *) CONFIG_I2C_MVTWSI_BASE;
+static struct mvtwsi_registers *twsi_get_base(struct i2c_adapter *adap)
+{
+ switch (adap->hwadapnr) {
+#ifdef CONFIG_I2C_MVTWSI_BASE0
+ case 0:
+ return (struct mvtwsi_registers *) CONFIG_I2C_MVTWSI_BASE0;
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE1
+ case 1:
+ return (struct mvtwsi_registers *) CONFIG_I2C_MVTWSI_BASE1;
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE2
+ case 2:
+ return (struct mvtwsi_registers *) CONFIG_I2C_MVTWSI_BASE2;
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE3
+ case 3:
+ return (struct mvtwsi_registers *) CONFIG_I2C_MVTWSI_BASE3;
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE4
+ case 4:
+ return (struct mvtwsi_registers *) CONFIG_I2C_MVTWSI_BASE4;
+#endif
+ default:
+ printf("Missing mvtwsi controller %d base\n", adap->hwadapnr);
+ break;
+ }
+
+ return NULL;
+}
/*
* Returned statuses are 0 for success and nonzero otherwise.
@@ -117,8 +145,9 @@ static struct mvtwsi_registers *twsi =
* Wait for IFLG to raise, or return 'timeout'; then if status is as expected,
* return 0 (ok) or return 'wrong status'.
*/
-static int twsi_wait(int expected_status)
+static int twsi_wait(struct i2c_adapter *adap, int expected_status)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
int control, status;
int timeout = 1000;
@@ -153,35 +182,40 @@ static u8 twsi_control_flags = MVTWSI_CONTROL_TWSIEN;
* Assert the START condition, either in a single I2C transaction
* or inside back-to-back ones (repeated starts).
*/
-static int twsi_start(int expected_status)
+static int twsi_start(struct i2c_adapter *adap, int expected_status)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
+
/* globally set TWSIEN in case it was not */
twsi_control_flags |= MVTWSI_CONTROL_TWSIEN;
/* assert START */
writel(twsi_control_flags | MVTWSI_CONTROL_START, &twsi->control);
/* wait for controller to process START */
- return twsi_wait(expected_status);
+ return twsi_wait(adap, expected_status);
}
/*
* Send a byte (i2c address or data).
*/
-static int twsi_send(u8 byte, int expected_status)
+static int twsi_send(struct i2c_adapter *adap, u8 byte, int expected_status)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
+
/* put byte in data register for sending */
writel(byte, &twsi->data);
/* clear any pending interrupt -- that'll cause sending */
writel(twsi_control_flags, &twsi->control);
/* wait for controller to receive byte and check ACK */
- return twsi_wait(expected_status);
+ return twsi_wait(adap, expected_status);
}
/*
* Receive a byte.
* Global mvtwsi_control_flags variable says if we should ack or nak.
*/
-static int twsi_recv(u8 *byte)
+static int twsi_recv(struct i2c_adapter *adap, u8 *byte)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
int expected_status, status;
/* compute expected status based on ACK bit in global control flags */
@@ -192,7 +226,7 @@ static int twsi_recv(u8 *byte)
/* acknowledge *previous state* and launch receive */
writel(twsi_control_flags, &twsi->control);
/* wait for controller to receive byte and assert ACK or NAK */
- status = twsi_wait(expected_status);
+ status = twsi_wait(adap, expected_status);
/* if we did receive expected byte then store it */
if (status == 0)
*byte = readl(&twsi->data);
@@ -204,8 +238,9 @@ static int twsi_recv(u8 *byte)
* Assert the STOP condition.
* This is also used to force the bus back in idle (SDA=SCL=1).
*/
-static int twsi_stop(int status)
+static int twsi_stop(struct i2c_adapter *adap, int status)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
int control, stop_status;
int timeout = 1000;
@@ -244,6 +279,7 @@ static unsigned int twsi_calc_freq(const int n, const int m)
*/
static void twsi_reset(struct i2c_adapter *adap)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
/* ensure controller will be enabled by any twsi*() function */
twsi_control_flags = MVTWSI_CONTROL_TWSIEN;
/* reset controller */
@@ -259,6 +295,7 @@ static void twsi_reset(struct i2c_adapter *adap)
static unsigned int twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
unsigned int requested_speed)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
unsigned int tmp_speed, highest_speed, n, m;
unsigned int baud = 0x44; /* baudrate at controller reset */
@@ -281,6 +318,8 @@ static unsigned int twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
static void twsi_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
{
+ struct mvtwsi_registers *twsi = twsi_get_base(adap);
+
/* reset controller */
twsi_reset(adap);
/* set speed */
@@ -289,7 +328,7 @@ static void twsi_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
writel(slaveadd, &twsi->slave_address);
writel(0, &twsi->xtnd_slave_addr);
/* assert STOP but don't care for the result */
- (void) twsi_stop(0);
+ (void) twsi_stop(adap, 0);
}
/*
@@ -297,7 +336,8 @@ static void twsi_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
* Common to i2c_probe, i2c_read and i2c_write.
* Expected address status will derive from direction bit (bit 0) in addr.
*/
-static int i2c_begin(int expected_start_status, u8 addr)
+static int i2c_begin(struct i2c_adapter *adap, int expected_start_status,
+ u8 addr)
{
int status, expected_addr_status;
@@ -307,10 +347,10 @@ static int i2c_begin(int expected_start_status, u8 addr)
else /* writing */
expected_addr_status = MVTWSI_STATUS_ADDR_W_ACK;
/* assert START */
- status = twsi_start(expected_start_status);
+ status = twsi_start(adap, expected_start_status);
/* send out the address if the start went well */
if (status == 0)
- status = twsi_send(addr, expected_addr_status);
+ status = twsi_send(adap, addr, expected_addr_status);
/* return ok or status of first failure to caller */
return status;
}
@@ -325,12 +365,12 @@ static int twsi_i2c_probe(struct i2c_adapter *adap, uchar chip)
int status;
/* begin i2c read */
- status = i2c_begin(MVTWSI_STATUS_START, (chip << 1) | 1);
+ status = i2c_begin(adap, MVTWSI_STATUS_START, (chip << 1) | 1);
/* dummy read was accepted: receive byte but NAK it. */
if (status == 0)
- status = twsi_recv(&dummy_byte);
+ status = twsi_recv(adap, &dummy_byte);
/* Stop transaction */
- twsi_stop(0);
+ twsi_stop(adap, 0);
/* return 0 or status of first failure */
return status;
}
@@ -351,15 +391,15 @@ static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
int status;
/* begin i2c write to send the address bytes */
- status = i2c_begin(MVTWSI_STATUS_START, (chip << 1));
+ status = i2c_begin(adap, MVTWSI_STATUS_START, (chip << 1));
/* send addr bytes */
while ((status == 0) && alen--)
- status = twsi_send(addr >> (8*alen),
+ status = twsi_send(adap, addr >> (8*alen),
MVTWSI_STATUS_DATA_W_ACK);
/* begin i2c read to receive eeprom data bytes */
if (status == 0)
- status = i2c_begin(
- MVTWSI_STATUS_REPEATED_START, (chip << 1) | 1);
+ status = i2c_begin(adap, MVTWSI_STATUS_REPEATED_START,
+ (chip << 1) | 1);
/* prepare ACK if at least one byte must be received */
if (length > 0)
twsi_control_flags |= MVTWSI_CONTROL_ACK;
@@ -369,10 +409,10 @@ static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
if (length == 0)
twsi_control_flags &= ~MVTWSI_CONTROL_ACK;
/* read current byte */
- status = twsi_recv(data++);
+ status = twsi_recv(adap, data++);
}
/* Stop transaction */
- status = twsi_stop(status);
+ status = twsi_stop(adap, status);
/* return 0 or status of first failure */
return status;
}
@@ -387,21 +427,51 @@ static int twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
int status;
/* begin i2c write to send the eeprom adress bytes then data bytes */
- status = i2c_begin(MVTWSI_STATUS_START, (chip << 1));
+ status = i2c_begin(adap, MVTWSI_STATUS_START, (chip << 1));
/* send addr bytes */
while ((status == 0) && alen--)
- status = twsi_send(addr >> (8*alen),
+ status = twsi_send(adap, addr >> (8*alen),
MVTWSI_STATUS_DATA_W_ACK);
/* send data bytes */
while ((status == 0) && (length-- > 0))
- status = twsi_send(*(data++), MVTWSI_STATUS_DATA_W_ACK);
+ status = twsi_send(adap, *(data++), MVTWSI_STATUS_DATA_W_ACK);
/* Stop transaction */
- status = twsi_stop(status);
+ status = twsi_stop(adap, status);
/* return 0 or status of first failure */
return status;
}
+#ifdef CONFIG_I2C_MVTWSI_BASE0
U_BOOT_I2C_ADAP_COMPLETE(twsi0, twsi_i2c_init, twsi_i2c_probe,
twsi_i2c_read, twsi_i2c_write,
twsi_i2c_set_bus_speed,
CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE, 0)
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE1
+U_BOOT_I2C_ADAP_COMPLETE(twsi1, twsi_i2c_init, twsi_i2c_probe,
+ twsi_i2c_read, twsi_i2c_write,
+ twsi_i2c_set_bus_speed,
+ CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE, 1)
+
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE2
+U_BOOT_I2C_ADAP_COMPLETE(twsi2, twsi_i2c_init, twsi_i2c_probe,
+ twsi_i2c_read, twsi_i2c_write,
+ twsi_i2c_set_bus_speed,
+ CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE, 2)
+
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE3
+U_BOOT_I2C_ADAP_COMPLETE(twsi3, twsi_i2c_init, twsi_i2c_probe,
+ twsi_i2c_read, twsi_i2c_write,
+ twsi_i2c_set_bus_speed,
+ CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE, 3)
+
+#endif
+#ifdef CONFIG_I2C_MVTWSI_BASE4
+U_BOOT_I2C_ADAP_COMPLETE(twsi4, twsi_i2c_init, twsi_i2c_probe,
+ twsi_i2c_read, twsi_i2c_write,
+ twsi_i2c_set_bus_speed,
+ CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE, 4)
+
+#endif
diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index 5a06d68af7..2a9fd56c95 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -497,7 +497,7 @@ int sunxi_emac_initialize(void)
/* Configure pin mux settings for MII Ethernet */
for (pin = SUNXI_GPA(0); pin <= SUNXI_GPA(17); pin++)
- sunxi_gpio_set_cfgpin(pin, SUNXI_GPA0_EMAC);
+ sunxi_gpio_set_cfgpin(pin, SUNXI_GPA_EMAC);
/* Set up clock gating */
setbits_le32(&ccm->ahb_gate0, 0x1 << AHB_GATE_OFFSET_EMAC);
diff --git a/drivers/power/axp152.c b/drivers/power/axp152.c
index 27c2c4c8da..740a3b41cd 100644
--- a/drivers/power/axp152.c
+++ b/drivers/power/axp152.c
@@ -8,17 +8,6 @@
#include <i2c.h>
#include <axp152.h>
-enum axp152_reg {
- AXP152_CHIP_VERSION = 0x3,
- AXP152_DCDC2_VOLTAGE = 0x23,
- AXP152_DCDC3_VOLTAGE = 0x27,
- AXP152_DCDC4_VOLTAGE = 0x2B,
- AXP152_LDO2_VOLTAGE = 0x2A,
- AXP152_SHUTDOWN = 0x32,
-};
-
-#define AXP152_POWEROFF (1 << 7)
-
static int axp152_write(enum axp152_reg reg, u8 val)
{
return i2c_write(0x30, reg, 1, &val, 1);
diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c
index f8c9b77be0..1d7be4991a 100644
--- a/drivers/power/axp209.c
+++ b/drivers/power/axp209.c
@@ -7,45 +7,9 @@
#include <common.h>
#include <i2c.h>
+#include <asm/arch/gpio.h>
#include <axp209.h>
-enum axp209_reg {
- AXP209_POWER_STATUS = 0x00,
- AXP209_CHIP_VERSION = 0x03,
- AXP209_DCDC2_VOLTAGE = 0x23,
- AXP209_DCDC3_VOLTAGE = 0x27,
- AXP209_LDO24_VOLTAGE = 0x28,
- AXP209_LDO3_VOLTAGE = 0x29,
- AXP209_IRQ_ENABLE1 = 0x40,
- AXP209_IRQ_ENABLE2 = 0x41,
- AXP209_IRQ_ENABLE3 = 0x42,
- AXP209_IRQ_ENABLE4 = 0x43,
- AXP209_IRQ_ENABLE5 = 0x44,
- AXP209_IRQ_STATUS5 = 0x4c,
- AXP209_SHUTDOWN = 0x32,
- AXP209_GPIO0_CTRL = 0x90,
- AXP209_GPIO1_CTRL = 0x92,
- AXP209_GPIO2_CTRL = 0x93,
- AXP209_GPIO_STATE = 0x94,
- AXP209_GPIO3_CTRL = 0x95,
-};
-
-#define AXP209_POWER_STATUS_ON_BY_DC (1 << 0)
-
-#define AXP209_IRQ5_PEK_UP (1 << 6)
-#define AXP209_IRQ5_PEK_DOWN (1 << 5)
-
-#define AXP209_POWEROFF (1 << 7)
-
-#define AXP209_GPIO_OUTPUT_LOW 0x00 /* Drive pin low */
-#define AXP209_GPIO_OUTPUT_HIGH 0x01 /* Drive pin high */
-#define AXP209_GPIO_INPUT 0x02 /* Float pin */
-
-/* GPIO3 is different from the others */
-#define AXP209_GPIO3_OUTPUT_LOW 0x00 /* Drive pin low, Output mode */
-#define AXP209_GPIO3_OUTPUT_HIGH 0x02 /* Float pin, Output mode */
-#define AXP209_GPIO3_INPUT 0x06 /* Float pin, Input mode */
-
static int axp209_write(enum axp209_reg reg, u8 val)
{
return i2c_write(0x34, reg, 1, &val, 1);
@@ -205,6 +169,9 @@ static u8 axp209_get_gpio_ctrl_reg(unsigned int pin)
int axp_gpio_direction_input(unsigned int pin)
{
+ if (pin == SUNXI_GPIO_AXP0_VBUS_DETECT)
+ return 0;
+
u8 reg = axp209_get_gpio_ctrl_reg(pin);
/* GPIO3 is "special" */
u8 val = (pin == 3) ? AXP209_GPIO3_INPUT : AXP209_GPIO_INPUT;
@@ -232,7 +199,10 @@ int axp_gpio_get_value(unsigned int pin)
u8 val, mask;
int rc;
- if (pin == 3) {
+ if (pin == SUNXI_GPIO_AXP0_VBUS_DETECT) {
+ rc = axp209_read(AXP209_POWER_STATUS, &val);
+ mask = AXP209_POWER_STATUS_VBUS_USABLE;
+ } else if (pin == 3) {
rc = axp209_read(AXP209_GPIO3_CTRL, &val);
mask = 1;
} else {
diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
index c2c3988804..dc3a7f19bd 100644
--- a/drivers/power/axp221.c
+++ b/drivers/power/axp221.c
@@ -14,6 +14,7 @@
#include <errno.h>
#include <asm/arch/p2wi.h>
#include <asm/arch/rsb.h>
+#include <asm/arch/gpio.h>
#include <axp221.h>
/*
@@ -385,54 +386,66 @@ int axp221_get_sid(unsigned int *sid)
return 0;
}
-int axp_get_vbus(void)
+int axp_gpio_direction_input(unsigned int pin)
{
- int ret;
- u8 val;
-
- ret = axp221_init();
- if (ret)
- return ret;
-
- ret = pmic_bus_read(AXP221_POWER_STATUS, &val);
- if (ret)
- return ret;
-
- return (val & AXP221_POWER_STATUS_VBUS_USABLE) ? 1 : 0;
+ switch (pin) {
+ case SUNXI_GPIO_AXP0_VBUS_DETECT:
+ return 0;
+ default:
+ return -EINVAL;
+ }
}
-static int axp_drivebus_setup(void)
+int axp_gpio_direction_output(unsigned int pin, unsigned int val)
{
int ret;
- ret = axp221_init();
- if (ret)
- return ret;
+ switch (pin) {
+ case SUNXI_GPIO_AXP0_VBUS_ENABLE:
+ ret = axp221_clrbits(AXP221_MISC_CTRL,
+ AXP221_MISC_CTRL_N_VBUSEN_FUNC);
+ if (ret)
+ return ret;
- /* Set N_VBUSEN pin to output / DRIVEBUS function */
- return axp221_clrbits(AXP221_MISC_CTRL, AXP221_MISC_CTRL_N_VBUSEN_FUNC);
+ return axp_gpio_set_value(pin, val);
+ default:
+ return -EINVAL;
+ }
}
-int axp_drivebus_enable(void)
+int axp_gpio_get_value(unsigned int pin)
{
int ret;
+ u8 val;
- ret = axp_drivebus_setup();
- if (ret)
- return ret;
+ switch (pin) {
+ case SUNXI_GPIO_AXP0_VBUS_DETECT:
+ ret = pmic_bus_read(AXP221_POWER_STATUS, &val);
+ if (ret)
+ return ret;
- /* Set DRIVEBUS high */
- return axp221_setbits(AXP221_VBUS_IPSOUT, AXP221_VBUS_IPSOUT_DRIVEBUS);
+ return !!(val & AXP221_POWER_STATUS_VBUS_AVAIL);
+ default:
+ return -EINVAL;
+ }
}
-int axp_drivebus_disable(void)
+int axp_gpio_set_value(unsigned int pin, unsigned int val)
{
int ret;
- ret = axp_drivebus_setup();
- if (ret)
- return ret;
+ switch (pin) {
+ case SUNXI_GPIO_AXP0_VBUS_ENABLE:
+ if (val)
+ ret = axp221_setbits(AXP221_VBUS_IPSOUT,
+ AXP221_VBUS_IPSOUT_DRIVEBUS);
+ else
+ ret = axp221_clrbits(AXP221_VBUS_IPSOUT,
+ AXP221_VBUS_IPSOUT_DRIVEBUS);
- /* Set DRIVEBUS low */
- return axp221_clrbits(AXP221_VBUS_IPSOUT, AXP221_VBUS_IPSOUT_DRIVEBUS);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
}
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 90aaec60d5..c9a6a16b89 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -235,52 +235,19 @@ static int sunxi_musb_init(struct musb *musb)
pr_debug("%s():\n", __func__);
- if (is_host_enabled(musb)) {
- int vbus_det = sunxi_name_to_gpio(CONFIG_USB0_VBUS_DET);
-
-#ifdef AXP_VBUS_DETECT
- if (!strcmp(CONFIG_USB0_VBUS_DET, "axp_vbus_detect")) {
- err = axp_get_vbus();
- if (err < 0)
- return err;
- } else {
-#endif
- if (vbus_det == -1) {
- eprintf("Error invalid Vusb-det pin\n");
- return -EINVAL;
- }
-
- err = gpio_request(vbus_det, "vbus0_det");
- if (err)
- return err;
-
- err = gpio_direction_input(vbus_det);
- if (err) {
- gpio_free(vbus_det);
- return err;
- }
-
- err = gpio_get_value(vbus_det);
- if (err < 0) {
- gpio_free(vbus_det);
- return -EIO;
- }
-
- gpio_free(vbus_det);
-#ifdef AXP_VBUS_DETECT
- }
-#endif
+ err = sunxi_usbc_request_resources(0);
+ if (err)
+ return err;
+ if (is_host_enabled(musb)) {
+ err = sunxi_usbc_vbus_detect(0);
if (err) {
eprintf("Error: A charger is plugged into the OTG\n");
+ sunxi_usbc_free_resources(0);
return -EIO;
}
}
- err = sunxi_usbc_request_resources(0);
- if (err)
- return err;
-
musb->isr = sunxi_musb_interrupt;
sunxi_usbc_enable(0);
diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
index 4e12150027..d2341b0e36 100644
--- a/drivers/video/sunxi_display.c
+++ b/drivers/video/sunxi_display.c
@@ -665,10 +665,10 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
for (pin = SUNXI_GPD(0); pin <= SUNXI_GPD(27); pin++)
#ifdef CONFIG_VIDEO_LCD_IF_PARALLEL
- sunxi_gpio_set_cfgpin(pin, SUNXI_GPD0_LCD0);
+ sunxi_gpio_set_cfgpin(pin, SUNXI_GPD_LCD0);
#endif
#ifdef CONFIG_VIDEO_LCD_IF_LVDS
- sunxi_gpio_set_cfgpin(pin, SUNXI_GPD0_LVDS0);
+ sunxi_gpio_set_cfgpin(pin, SUNXI_GPD_LVDS0);
#endif
sunxi_lcdc_pll_set(0, mode->pixclock_khz, &clk_div, &clk_double);
@@ -779,8 +779,8 @@ static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,
&lcdc->tcon1_timing_sync);
if (use_portd_hvsync) {
- sunxi_gpio_set_cfgpin(SUNXI_GPD(26), SUNXI_GPD0_LCD0);
- sunxi_gpio_set_cfgpin(SUNXI_GPD(27), SUNXI_GPD0_LCD0);
+ sunxi_gpio_set_cfgpin(SUNXI_GPD(26), SUNXI_GPD_LCD0);
+ sunxi_gpio_set_cfgpin(SUNXI_GPD(27), SUNXI_GPD_LCD0);
val = 0;
if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
OpenPOWER on IntegriCloud