Skip to content

Commit

Permalink
apply newest patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Sugar authored and csjamesdeng committed Oct 12, 2018
1 parent ff98af5 commit 0056b9c
Show file tree
Hide file tree
Showing 59 changed files with 1,499 additions and 1,629 deletions.
5 changes: 5 additions & 0 deletions arch/arm/boot/dts/sun8iw12p1-clk.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,11 @@ clocks {
};

/*cpus space clocks from PRCM-SPEC*/
clk_cpurtwi1: cpurtwi1 {
#clock-cells = <0>;
compatible = "allwinner,periph-cpus-clock";
clock-output-names = "cpurtwi1";
};
clk_cpurcir: cpurcir {
#clock-cells = <0>;
compatible = "allwinner,periph-cpus-clock";
Expand Down
17 changes: 17 additions & 0 deletions arch/arm/boot/dts/sun8iw12p1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@
allwinner,pull = <1>;
};

twi4_pins_a: twi4@0 {
allwinner,pins = "PL8", "PL9";
allwinner,pname = "twi4_scl", "twi4_sda";
allwinner,function = "s_twi1";
allwinner,muxsel = <2>;
allwinner,drive = <1>;
allwinner,pull = <0>;
};

twi4_pins_b: twi4@1 {
allwinner,pins = "PL8", "PL9";
allwainner,function = "io_disabled";
allwinner,muxsel = <7>;
allwinner,drive = <1>;
allwinner,pull = <0>;
};

s_jtag0_pins_a: s_jtag0@0 {
allwinner,pins = "PL4", "PL5", "PL6", "PL7";
allwinner,function = "s_jtag0";
Expand Down
16 changes: 16 additions & 0 deletions arch/arm/boot/dts/sun8iw12p1.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
twi1 = &twi1;
twi2 = &twi2;
twi3 = &twi3;
twi4 = &twi4;
spi0 = &spi0;
spi1 = &spi1;
spi2 = &spi2;
Expand Down Expand Up @@ -633,6 +634,21 @@
status = "disabled";
};

twi4: twi@0x07081800{
#address-cells = <1>;
#size-cells = <0>;
compatible = "allwinner,sun8i-twi";
device_type = "twi4";
reg = <0x0 0x07081800 0x0 0x400>;
interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk_cpurtwi1>;
clock-frequency = <200000>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&twi4_pins_a>;
pinctrl-1 = <&twi4_pins_b>;
status = "disabled";
};

usbc0:usbc0@0 {
device_type = "usbc0";
compatible = "allwinner,sunxi-otg-manager";
Expand Down
8 changes: 5 additions & 3 deletions arch/arm/mach-sunxi/include/mach/uncompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
#include <asm/barrier.h>
#include <linux/bitops.h>

#define SUNXI_UART0_PBASE 0x01c28000
#ifdef CONFIG_DEBUG_LL
#define SUNXI_UART0_PBASE CONFIG_DEBUG_UART_PHYS
#define UART_TF (*(volatile unsigned long*)(SUNXI_UART0_PBASE + 0x00))
#define UART_SR (*(volatile unsigned long*)(SUNXI_UART0_PBASE + 0x7C))
#define TX_BUSY BIT(1)
Expand All @@ -35,12 +36,13 @@
*/
static inline void putc(int c)
{
#if 0
while (!(UART_SR & TX_BUSY))
cpu_relax();
UART_TF = c;
#endif
}
#else
static inline void putc(int c){}
#endif
static inline void flush(void) {}
static inline void arch_decomp_setup(void) {}

Expand Down
3 changes: 3 additions & 0 deletions drivers/clk/sunxi/clk-sun8iw12.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ static const char *cpurahbs_parents[] = {"cpurcpus"};
static const char *cpurapbs1_parents[] = {"cpurahbs"};
static const char *cpurapbs2_pll_parents[] = {"pll_periph0"};
static const char *cpurapbs2_parents[] = {"hosc", "losc", "iosc", "cpurapbs2_pll"};
static const char *apbs2mod_parents[] = {"cpurapbs2"};
static const char *cpurdev_parents[] = {"losc", "hosc"};
static const char *cpurpio_parents[] = {"cpurapbs1"};
static const char *losc_parents[] = {"losc"};
Expand Down Expand Up @@ -573,6 +574,7 @@ SUNXI_CLK_PERIPH(cpurapbs1, 0, 0, 0, CPUS_AP
SUNXI_CLK_PERIPH(cpurapbs2_pll, 0, 0, 0, CPUS_APBS2_CFG, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &clk_lock, NULL, 0);
SUNXI_CLK_PERIPH(cpurapbs2, CPUS_APBS2_CFG, 24, 2, CPUS_APBS2_CFG, 0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, &clk_lock, NULL, 0);
SUNXI_CLK_PERIPH(cpurcir, CPUS_CIR_CFG, 24, 1, CPUS_CIR_CFG, 0, 5, 8, 2, 0, CPUS_CIR_CFG, CPUS_CIR_GATE, CPUS_CIR_GATE, 0, 31, 16, 0, 0, &clk_lock, NULL, 0);
SUNXI_CLK_PERIPH(cpurtwi1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CPUS_TWI_GATE, CPUS_TWI_GATE, 0, 0, 17, 1, 0, &clk_lock, NULL, 0);
SUNXI_CLK_PERIPH(losc_out, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOSC_OUT_GATE, 0, 0, 0, 0, 0, &clk_lock, NULL, 0);
SUNXI_CLK_PERIPH(cpurpio, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &clk_lock, NULL, 0);
SUNXI_CLK_PERIPH(spwm, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CPUS_PWM_GATE, CPUS_PWM_GATE, 0, 0, 16, 0, 0, &clk_lock, NULL, 0);
Expand Down Expand Up @@ -680,6 +682,7 @@ struct periph_init_data sunxi_periphs_cpus_init[] = {
{"cpurapbs1", CLK_GET_RATE_NOCACHE|CLK_READONLY, cpurapbs1_parents, ARRAY_SIZE(cpurapbs1_parents), &sunxi_clk_periph_cpurapbs1 },
{"cpurapbs2_pll", CLK_GET_RATE_NOCACHE|CLK_READONLY, cpurapbs2_pll_parents, ARRAY_SIZE(cpurapbs2_pll_parents), &sunxi_clk_periph_cpurapbs2_pll },
{"cpurapbs2", CLK_GET_RATE_NOCACHE|CLK_READONLY, cpurapbs2_parents, ARRAY_SIZE(cpurapbs2_parents), &sunxi_clk_periph_cpurapbs2 },
{"cpurtwi1", 0, apbs2mod_parents, ARRAY_SIZE(apbs2mod_parents), &sunxi_clk_periph_cpurtwi1 },
{"cpurcir", CLK_GET_RATE_NOCACHE, cpurdev_parents, ARRAY_SIZE(cpurdev_parents), &sunxi_clk_periph_cpurcir },
{"losc_out", 0, losc_parents, ARRAY_SIZE(losc_parents), &sunxi_clk_periph_losc_out },
{"cpurpio", CLK_GET_RATE_NOCACHE|CLK_READONLY, cpurpio_parents, ARRAY_SIZE(cpurpio_parents), &sunxi_clk_periph_cpurpio },
Expand Down
18 changes: 10 additions & 8 deletions drivers/i2c/busses/i2c-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ static int i2c_gpio_getscl(void *data)
static int of_i2c_gpio_get_pins(struct device_node *np,
unsigned int *sda_pin, unsigned int *scl_pin)
{
if (of_gpio_count(np) < 2)
return -ENODEV;

*sda_pin = of_get_gpio(np, 0);
*scl_pin = of_get_gpio(np, 1);
if (of_gpio_count(np) < 2) {
*sda_pin = of_get_named_gpio_flags(np, "i2c-gpio,sda", 0, NULL);
*scl_pin = of_get_named_gpio_flags(np, "i2c-gpio,scl", 0, NULL);
} else {
*sda_pin = of_get_gpio(np, 0);
*scl_pin = of_get_gpio(np, 1);

if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER)
return -EPROBE_DEFER;
}

if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) {
pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n",
Expand Down Expand Up @@ -220,7 +222,7 @@ static int i2c_gpio_probe(struct platform_device *pdev)
adap->dev.parent = &pdev->dev;
adap->dev.of_node = pdev->dev.of_node;

adap->nr = pdev->id;
adap->nr = -1;
ret = i2c_bit_add_numbered_bus(adap);
if (ret)
return ret;
Expand Down
50 changes: 19 additions & 31 deletions drivers/i2c/busses/i2c-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ module_param_named(transfer_debug, bus_transfer_dbg,
#define SUNXI_I2C_SFAIL -3 /* start fail */
#define SUNXI_I2C_TFAIL -4 /* stop fail */

static int twi_used_mask;

/* I2C transfer status */
enum {
I2C_XFER_IDLE = 0x1,
Expand Down Expand Up @@ -337,11 +335,6 @@ static int sunxi_i2c_xfer_complete(struct sunxi_i2c *i2c, int code);
static int
sunxi_i2c_do_xfer(struct sunxi_i2c *i2c, struct i2c_msg *msgs, int num);

static int twi_chan_is_enable(int _ch)
{
return twi_used_mask & SUNXI_TWI_CHAN_MASK(_ch);
}

static int twi_select_gpio_state(struct pinctrl *pctrl, char *name, u32 no)
{
int ret = 0;
Expand All @@ -367,9 +360,6 @@ static int twi_request_gpio(struct sunxi_i2c *i2c)
I2C_DBG("Pinctrl init %d ... [%s]\n",
i2c->bus_num, i2c->adap.dev.parent->init_name);

if (!twi_chan_is_enable(i2c->bus_num))
return -1;

i2c->pctrl = devm_pinctrl_get(i2c->adap.dev.parent);
if (IS_ERR(i2c->pctrl)) {
I2C_ERR("TWI%d devm_pinctrl_get() failed! return %ld\n",
Expand All @@ -395,7 +385,7 @@ static int twi_start(void __iomem *base_addr, int bus_num)
while ((twi_get_start(base_addr) == 1) && (--timeout))
;
if (timeout == 0) {
I2C_ERR("[i2c%d] START can't sendout!\n", bus_num);
I2C_ERR("[sunxi-i2c%d] START can't sendout!\n", bus_num);
return SUNXI_I2C_FAIL;
}

Expand All @@ -411,7 +401,7 @@ static int twi_restart(void __iomem *base_addr, int bus_num)
while ((twi_get_start(base_addr) == 1) && (--timeout))
;
if (timeout == 0) {
I2C_ERR("[i2c%d] Restart can't sendout!\n", bus_num);
I2C_ERR("[sunxi-i2c%d] Restart can't sendout!\n", bus_num);
return SUNXI_I2C_FAIL;
}

Expand All @@ -429,7 +419,7 @@ static int twi_stop(void __iomem *base_addr, int bus_num)
while ((twi_get_stop(base_addr) == 1) && (--timeout))
;
if (timeout == 0) {
I2C_ERR("[i2c%d] STOP can't sendout!\n", bus_num);
I2C_ERR("[sunxi-i2c%d] STOP can't sendout!\n", bus_num);
return SUNXI_I2C_TFAIL;
}

Expand All @@ -438,7 +428,7 @@ static int twi_stop(void __iomem *base_addr, int bus_num)
&& (--timeout))
;
if (timeout == 0) {
I2C_ERR("[i2c%d] i2c state(0x%08x) isn't idle(0xf8)\n",
I2C_ERR("[sunxi-i2c%d] i2c state(0x%08x) isn't idle(0xf8)\n",
bus_num, readl(base_addr + TWI_STAT_REG));
return SUNXI_I2C_TFAIL;
}
Expand All @@ -450,7 +440,7 @@ static int twi_stop(void __iomem *base_addr, int bus_num)
;

if (timeout == 0) {
I2C_ERR("[i2c%d] i2c lcr(0x%08x) isn't idle(0x3a)\n",
I2C_ERR("[sunxi-i2c%d] i2c lcr(0x%08x) isn't idle(0x3a)\n",
bus_num, readl(base_addr + TWI_LCR_REG));
return SUNXI_I2C_TFAIL;
}
Expand Down Expand Up @@ -539,7 +529,7 @@ static int twi_send_clk_9pulse(void __iomem *base_addr, int bus_num)
twi_disable_lcr(base_addr, twi_scl);
status = SUNXI_I2C_OK;
} else {
I2C_ERR("[i2c%d] SDA is still Stuck Low, failed.\n", bus_num);
I2C_ERR("[sunxi-i2c%d] SDA is still Stuck Low, failed.\n", bus_num);
twi_disable_lcr(base_addr, twi_scl);
status = SUNXI_I2C_FAIL;
}
Expand Down Expand Up @@ -1053,19 +1043,19 @@ static int sunxi_i2c_hw_init(struct sunxi_i2c *i2c,

ret = twi_regulator_request(pdata);
if (ret < 0) {
I2C_ERR("[i2c%d] request regulator failed!\n", i2c->bus_num);
I2C_ERR("[sunxi-i2c%d] request regulator failed!\n", i2c->bus_num);
return -1;
}
twi_regulator_enable(pdata);

ret = twi_request_gpio(i2c);
if (ret < 0) {
I2C_ERR("[i2c%d] request i2c gpio failed!\n", i2c->bus_num);
I2C_ERR("[sunxi-i2c%d] request i2c gpio failed!\n", i2c->bus_num);
return -1;
}

if (sunxi_i2c_clk_init(i2c)) {
I2C_ERR("[i2c%d] init i2c clock failed!\n", i2c->bus_num);
I2C_ERR("[sunxi-i2c%d] init i2c clock failed!\n", i2c->bus_num);
return -1;
}

Expand Down Expand Up @@ -1190,13 +1180,12 @@ static int sunxi_i2c_probe(struct platform_device *pdev)
}
pdev->dev.platform_data = pdata;

pdev->id = of_alias_get_id(np, "twi");
if (pdev->id < 0) {
pdata->bus_num = of_alias_get_id(np, "twi");
if (pdata->bus_num < 0) {
I2C_ERR("I2C failed to get alias id\n");
ret = -EINVAL;
goto emem;
}
pdata->bus_num = pdev->id;

mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (mem_res == NULL) {
Expand Down Expand Up @@ -1234,7 +1223,7 @@ static int sunxi_i2c_probe(struct platform_device *pdev)

pdev->dev.release = sunxi_i2c_release;
i2c->adap.owner = THIS_MODULE;
i2c->adap.nr = pdata->bus_num;
i2c->adap.nr = pdata->bus_num;;
i2c->adap.retries = 3;
i2c->adap.timeout = 5*HZ;
i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
Expand Down Expand Up @@ -1267,14 +1256,13 @@ static int sunxi_i2c_probe(struct platform_device *pdev)
ret = request_irq(irq, sunxi_i2c_handler, int_flag,
i2c->adap.name, i2c);
if (ret) {
I2C_ERR("[i2c%d] requeset irq failed!\n", i2c->bus_num);
I2C_ERR("[sunxi-i2c%d] requeset irq failed!\n", i2c->bus_num);
goto ereqirq;
}

i2c->adap.algo_data = i2c;
i2c->adap.dev.parent = &pdev->dev;
i2c->adap.dev.of_node = pdev->dev.of_node;
twi_used_mask |= SUNXI_TWI_CHAN_MASK(pdev->id);

if (sunxi_i2c_hw_init(i2c, pdata)) {
ret = -EIO;
Expand All @@ -1283,7 +1271,7 @@ static int sunxi_i2c_probe(struct platform_device *pdev)

ret = i2c_add_numbered_adapter(&i2c->adap);
if (ret < 0) {
I2C_ERR("[i2c%d] failed to add adapter\n", i2c->bus_num);
I2C_ERR("[sunxi-i2c%d] failed to add adapter\n", i2c->bus_num);
goto eadapt;
}

Expand Down Expand Up @@ -1334,7 +1322,7 @@ static int sunxi_i2c_remove(struct platform_device *pdev)
{
struct sunxi_i2c *i2c = platform_get_drvdata(pdev);

I2C_DBG("[i2c.%d] remove ...\n", i2c->bus_num);
I2C_DBG("[sunxi-i2c.%d] remove ...\n", i2c->bus_num);

platform_set_drvdata(pdev, NULL);
i2c_del_adapter(&i2c->adap);
Expand Down Expand Up @@ -1381,15 +1369,15 @@ static int sunxi_i2c_suspend(struct device *dev)
i2c->suspended = 1;

if (sunxi_i2c_clk_exit(i2c)) {
I2C_ERR("[i2c%d] suspend failed..\n", i2c->bus_num);
I2C_ERR("[sunxi-i2c%d] suspend failed..\n", i2c->bus_num);
i2c->suspended = 0;
return -1;
}

twi_select_gpio_state(i2c->pctrl, PINCTRL_STATE_SLEEP, i2c->bus_num);
twi_regulator_disable(dev->platform_data);

I2C_DBG("[i2c%d] suspend okay..\n", i2c->bus_num);
I2C_DBG("[sunxi-i2c%d] suspend okay..\n", i2c->bus_num);
return 0;
}

Expand All @@ -1410,13 +1398,13 @@ static int sunxi_i2c_resume(struct device *dev)
twi_select_gpio_state(i2c->pctrl, PINCTRL_STATE_DEFAULT, i2c->bus_num);

if (sunxi_i2c_clk_init(i2c)) {
I2C_ERR("[i2c%d] resume failed..\n", i2c->bus_num);
I2C_ERR("[sunxi-i2c%d] resume failed..\n", i2c->bus_num);
return -1;
}

twi_soft_reset(i2c->base_addr);

I2C_DBG("[i2c%d] resume okay..\n", i2c->bus_num);
I2C_DBG("[sunxi-i2c%d] resume okay..\n", i2c->bus_num);
return 0;
}

Expand Down
Loading

0 comments on commit 0056b9c

Please sign in to comment.