diff --git a/arch/arm/boot/dts/nintendo3ds.dtsi b/arch/arm/boot/dts/nintendo3ds.dtsi index ccffd45ca7115a..c2387c3c62e1d8 100755 --- a/arch/arm/boot/dts/nintendo3ds.dtsi +++ b/arch/arm/boot/dts/nintendo3ds.dtsi @@ -230,7 +230,7 @@ sc16is750: infrared@4d { compatible = "nxp,sc16is750"; reg = <0x4d>; - clock-frequency = <18432000>; + clocks = <&irclk>; interrupts-extended = <&gpio3 1 IRQ_TYPE_EDGE_FALLING>; @@ -361,6 +361,13 @@ clock-output-names = "3ds:refclk134mhz"; }; + irclk: xtal18mhz { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <18432000>; + clock-output-names = "3ds:xtal18mhz"; + }; + sdclk: refclk67mhz { compatible = "fixed-factor-clock"; clocks = <&refclk>; diff --git a/drivers/platform/nintendo3ds/ctr_i2c.c b/drivers/platform/nintendo3ds/ctr_i2c.c index 94137321dc88a0..69363a8dbce66b 100755 --- a/drivers/platform/nintendo3ds/ctr_i2c.c +++ b/drivers/platform/nintendo3ds/ctr_i2c.c @@ -94,34 +94,28 @@ static int ctr_i2c_recv(struct ctr_i2c *i2c, u8 *byte, unsigned flags) return err; } -static int ctr_i2c_stop(struct ctr_i2c *i2c) -{ - u8 data; - return ctr_i2c_recv(i2c, &data, I2C_CNT_LAST); -} - static int ctr_i2c_select_device(struct ctr_i2c *i2c, struct i2c_msg *msg) { return ctr_i2c_send(i2c, i2c_8bit_addr_from_msg(msg), I2C_CNT_START); } -static int ctr_i2c_msg_read(struct ctr_i2c *i2c, u8 *buf, int len) +static int ctr_i2c_msg_read(struct ctr_i2c *i2c, u8 *buf, int len, bool last) { int i; for (i = 0; i < len; i++) { - if (ctr_i2c_recv(i2c, &buf[i], I2C_CNT_ERRACK)) + unsigned flag = (last && (i==(len-1))) ? I2C_CNT_LAST : I2C_CNT_ERRACK; + if (ctr_i2c_recv(i2c, &buf[i], flag)) return i; } - return len; } -static int ctr_i2c_msg_write(struct ctr_i2c *i2c, u8 *buf, int len) +static int ctr_i2c_msg_write(struct ctr_i2c *i2c, u8 *buf, int len, bool last) { int i; - for (i = 0; i < len; i++) { - if (ctr_i2c_send(i2c, buf[i], 0)) + unsigned flag = (last && (i==(len-1))) ? I2C_CNT_LAST : 0; + if (ctr_i2c_send(i2c, buf[i], flag)) return i; if (!(ctr_i2c_read_cnt(i2c) & I2C_CNT_ERRACK)) { @@ -130,7 +124,6 @@ static int ctr_i2c_msg_write(struct ctr_i2c *i2c, u8 *buf, int len) return i; } } - return len; } @@ -151,10 +144,11 @@ static int ctr_i2c_master_xfer(struct i2c_adapter *adap, ctr_i2c_select_device(i2c, msg); if (msg->len != 0) { + bool last = i == (num-1); if (msg->flags & I2C_M_RD) { - plen = ctr_i2c_msg_read(i2c, msg->buf, msg->len); + plen = ctr_i2c_msg_read(i2c, msg->buf, msg->len, last); } else { - plen = ctr_i2c_msg_write(i2c, msg->buf, msg->len); + plen = ctr_i2c_msg_write(i2c, msg->buf, msg->len, last); } if (plen != msg->len) @@ -164,8 +158,6 @@ static int ctr_i2c_master_xfer(struct i2c_adapter *adap, msg++; } - ctr_i2c_stop(i2c); - return i; }