i2c: tegra: Add missing new line characters
[cascardo/linux.git] / drivers / i2c / busses / i2c-tegra.c
index b126dba..7f31a10 100644 (file)
 
 #define I2C_CNFG                               0x000
 #define I2C_CNFG_DEBOUNCE_CNT_SHIFT            12
-#define I2C_CNFG_PACKET_MODE_EN                        (1<<10)
-#define I2C_CNFG_NEW_MASTER_FSM                        (1<<11)
-#define I2C_CNFG_MULTI_MASTER_MODE             (1<<17)
+#define I2C_CNFG_PACKET_MODE_EN                        BIT(10)
+#define I2C_CNFG_NEW_MASTER_FSM                        BIT(11)
+#define I2C_CNFG_MULTI_MASTER_MODE             BIT(17)
 #define I2C_STATUS                             0x01C
 #define I2C_SL_CNFG                            0x020
-#define I2C_SL_CNFG_NACK                       (1<<1)
-#define I2C_SL_CNFG_NEWSL                      (1<<2)
+#define I2C_SL_CNFG_NACK                       BIT(1)
+#define I2C_SL_CNFG_NEWSL                      BIT(2)
 #define I2C_SL_ADDR1                           0x02c
 #define I2C_SL_ADDR2                           0x030
 #define I2C_TX_FIFO                            0x050
 #define I2C_RX_FIFO                            0x054
 #define I2C_PACKET_TRANSFER_STATUS             0x058
 #define I2C_FIFO_CONTROL                       0x05c
-#define I2C_FIFO_CONTROL_TX_FLUSH              (1<<1)
-#define I2C_FIFO_CONTROL_RX_FLUSH              (1<<0)
+#define I2C_FIFO_CONTROL_TX_FLUSH              BIT(1)
+#define I2C_FIFO_CONTROL_RX_FLUSH              BIT(0)
 #define I2C_FIFO_CONTROL_TX_TRIG_SHIFT         5
 #define I2C_FIFO_CONTROL_RX_TRIG_SHIFT         2
 #define I2C_FIFO_STATUS                                0x060
 #define I2C_FIFO_STATUS_RX_SHIFT               0
 #define I2C_INT_MASK                           0x064
 #define I2C_INT_STATUS                         0x068
-#define I2C_INT_PACKET_XFER_COMPLETE           (1<<7)
-#define I2C_INT_ALL_PACKETS_XFER_COMPLETE      (1<<6)
-#define I2C_INT_TX_FIFO_OVERFLOW               (1<<5)
-#define I2C_INT_RX_FIFO_UNDERFLOW              (1<<4)
-#define I2C_INT_NO_ACK                         (1<<3)
-#define I2C_INT_ARBITRATION_LOST               (1<<2)
-#define I2C_INT_TX_FIFO_DATA_REQ               (1<<1)
-#define I2C_INT_RX_FIFO_DATA_REQ               (1<<0)
+#define I2C_INT_PACKET_XFER_COMPLETE           BIT(7)
+#define I2C_INT_ALL_PACKETS_XFER_COMPLETE      BIT(6)
+#define I2C_INT_TX_FIFO_OVERFLOW               BIT(5)
+#define I2C_INT_RX_FIFO_UNDERFLOW              BIT(4)
+#define I2C_INT_NO_ACK                         BIT(3)
+#define I2C_INT_ARBITRATION_LOST               BIT(2)
+#define I2C_INT_TX_FIFO_DATA_REQ               BIT(1)
+#define I2C_INT_RX_FIFO_DATA_REQ               BIT(0)
 #define I2C_CLK_DIVISOR                                0x06c
 #define I2C_CLK_DIVISOR_STD_FAST_MODE_SHIFT    16
 #define I2C_CLK_MULTIPLIER_STD_FAST_MODE       8
 
 #define DVC_CTRL_REG1                          0x000
-#define DVC_CTRL_REG1_INTR_EN                  (1<<10)
+#define DVC_CTRL_REG1_INTR_EN                  BIT(10)
 #define DVC_CTRL_REG2                          0x004
 #define DVC_CTRL_REG3                          0x008
-#define DVC_CTRL_REG3_SW_PROG                  (1<<26)
-#define DVC_CTRL_REG3_I2C_DONE_INTR_EN         (1<<30)
+#define DVC_CTRL_REG3_SW_PROG                  BIT(26)
+#define DVC_CTRL_REG3_I2C_DONE_INTR_EN         BIT(30)
 #define DVC_STATUS                             0x00c
-#define DVC_STATUS_I2C_DONE_INTR               (1<<30)
+#define DVC_STATUS_I2C_DONE_INTR               BIT(30)
 
 #define I2C_ERR_NONE                           0x00
 #define I2C_ERR_NO_ACK                         0x01
 #define PACKET_HEADER0_HEADER_SIZE_SHIFT       28
 #define PACKET_HEADER0_PACKET_ID_SHIFT         16
 #define PACKET_HEADER0_CONT_ID_SHIFT           12
-#define PACKET_HEADER0_PROTOCOL_I2C            (1<<4)
-
-#define I2C_HEADER_HIGHSPEED_MODE              (1<<22)
-#define I2C_HEADER_CONT_ON_NAK                 (1<<21)
-#define I2C_HEADER_SEND_START_BYTE             (1<<20)
-#define I2C_HEADER_READ                                (1<<19)
-#define I2C_HEADER_10BIT_ADDR                  (1<<18)
-#define I2C_HEADER_IE_ENABLE                   (1<<17)
-#define I2C_HEADER_REPEAT_START                        (1<<16)
-#define I2C_HEADER_CONTINUE_XFER               (1<<15)
+#define PACKET_HEADER0_PROTOCOL_I2C            BIT(4)
+
+#define I2C_HEADER_HIGHSPEED_MODE              BIT(22)
+#define I2C_HEADER_CONT_ON_NAK                 BIT(21)
+#define I2C_HEADER_SEND_START_BYTE             BIT(20)
+#define I2C_HEADER_READ                                BIT(19)
+#define I2C_HEADER_10BIT_ADDR                  BIT(18)
+#define I2C_HEADER_IE_ENABLE                   BIT(17)
+#define I2C_HEADER_REPEAT_START                        BIT(16)
+#define I2C_HEADER_CONTINUE_XFER               BIT(15)
 #define I2C_HEADER_MASTER_ADDR_SHIFT           12
 #define I2C_HEADER_SLAVE_ADDR_SHIFT            1
 
 #define I2C_CONFIG_LOAD                                0x08C
-#define I2C_MSTR_CONFIG_LOAD                   (1 << 0)
-#define I2C_SLV_CONFIG_LOAD                    (1 << 1)
-#define I2C_TIMEOUT_CONFIG_LOAD                        (1 << 2)
+#define I2C_MSTR_CONFIG_LOAD                   BIT(0)
+#define I2C_SLV_CONFIG_LOAD                    BIT(1)
+#define I2C_TIMEOUT_CONFIG_LOAD                        BIT(2)
 
 #define I2C_CLKEN_OVERRIDE                     0x090
-#define I2C_MST_CORE_CLKEN_OVR                 (1 << 0)
+#define I2C_MST_CORE_CLKEN_OVR                 BIT(0)
 
 /*
  * msg_end_type: The bus control which need to be send at end of transfer.
@@ -193,7 +193,8 @@ struct tegra_i2c_dev {
        bool is_multimaster_mode;
 };
 
-static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned long reg)
+static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val,
+                      unsigned long reg)
 {
        writel(val, i2c_dev->base + reg);
 }
@@ -244,15 +245,17 @@ static void i2c_readsl(struct tegra_i2c_dev *i2c_dev, void *data,
 
 static void tegra_i2c_mask_irq(struct tegra_i2c_dev *i2c_dev, u32 mask)
 {
-       u32 int_mask = i2c_readl(i2c_dev, I2C_INT_MASK);
-       int_mask &= ~mask;
+       u32 int_mask;
+
+       int_mask = i2c_readl(i2c_dev, I2C_INT_MASK) & ~mask;
        i2c_writel(i2c_dev, int_mask, I2C_INT_MASK);
 }
 
 static void tegra_i2c_unmask_irq(struct tegra_i2c_dev *i2c_dev, u32 mask)
 {
-       u32 int_mask = i2c_readl(i2c_dev, I2C_INT_MASK);
-       int_mask |= mask;
+       u32 int_mask;
+
+       int_mask = i2c_readl(i2c_dev, I2C_INT_MASK) | mask;
        i2c_writel(i2c_dev, int_mask, I2C_INT_MASK);
 }
 
@@ -260,6 +263,7 @@ static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev)
 {
        unsigned long timeout = jiffies + HZ;
        u32 val = i2c_readl(i2c_dev, I2C_FIFO_CONTROL);
+
        val |= I2C_FIFO_CONTROL_TX_FLUSH | I2C_FIFO_CONTROL_RX_FLUSH;
        i2c_writel(i2c_dev, val, I2C_FIFO_CONTROL);
 
@@ -385,7 +389,8 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev)
  */
 static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)
 {
-       u32 val = 0;
+       u32 val;
+
        val = dvc_readl(i2c_dev, DVC_CTRL_REG3);
        val |= DVC_CTRL_REG3_SW_PROG;
        val |= DVC_CTRL_REG3_I2C_DONE_INTR_EN;
@@ -399,6 +404,7 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)
 static inline int tegra_i2c_clock_enable(struct tegra_i2c_dev *i2c_dev)
 {
        int ret;
+
        if (!i2c_dev->hw->has_single_clk_source) {
                ret = clk_enable(i2c_dev->fast_clk);
                if (ret < 0) {
@@ -460,11 +466,11 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
 
        if (!i2c_dev->is_dvc) {
                u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
+
                sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
                i2c_writel(i2c_dev, sl_cfg, I2C_SL_CNFG);
                i2c_writel(i2c_dev, 0xfc, I2C_SL_ADDR1);
                i2c_writel(i2c_dev, 0x00, I2C_SL_ADDR2);
-
        }
 
        val = 7 << I2C_FIFO_CONTROL_TX_TRIG_SHIFT |
@@ -643,9 +649,10 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
                return 0;
 
        /*
-        * NACK interrupt is generated before the I2C controller generates the
-        * STOP condition on the bus. So wait for 2 clock periods before resetting
-        * the controller so that STOP condition has been delivered properly.
+        * NACK interrupt is generated before the I2C controller generates
+        * the STOP condition on the bus. So wait for 2 clock periods
+        * before resetting the controller so that the STOP condition has
+        * been delivered properly.
         */
        if (i2c_dev->msg_err == I2C_ERR_NO_ACK)
                udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
@@ -678,6 +685,7 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 
        for (i = 0; i < num; i++) {
                enum msg_end_type end_type = MSG_END_STOP;
+
                if (i < (num - 1)) {
                        if (msgs[i + 1].flags & I2C_M_NOSTART)
                                end_type = MSG_END_CONTINUE;
@@ -825,7 +833,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 
        div_clk = devm_clk_get(&pdev->dev, "div-clk");
        if (IS_ERR(div_clk)) {
-               dev_err(&pdev->dev, "missing controller clock");
+               dev_err(&pdev->dev, "missing controller clock\n");
                return PTR_ERR(div_clk);
        }
 
@@ -843,7 +851,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 
        i2c_dev->rst = devm_reset_control_get(&pdev->dev, "i2c");
        if (IS_ERR(i2c_dev->rst)) {
-               dev_err(&pdev->dev, "missing controller reset");
+               dev_err(&pdev->dev, "missing controller reset\n");
                return PTR_ERR(i2c_dev->rst);
        }
 
@@ -863,7 +871,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
        if (!i2c_dev->hw->has_single_clk_source) {
                fast_clk = devm_clk_get(&pdev->dev, "fast-clk");
                if (IS_ERR(fast_clk)) {
-                       dev_err(&pdev->dev, "missing fast clock");
+                       dev_err(&pdev->dev, "missing fast clock\n");
                        return PTR_ERR(fast_clk);
                }
                i2c_dev->fast_clk = fast_clk;
@@ -911,7 +919,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 
        ret = tegra_i2c_init(i2c_dev);
        if (ret) {
-               dev_err(&pdev->dev, "Failed to initialize i2c controller");
+               dev_err(&pdev->dev, "Failed to initialize i2c controller\n");
                goto disable_div_clk;
        }
 
@@ -932,10 +940,8 @@ static int tegra_i2c_probe(struct platform_device *pdev)
        i2c_dev->adapter.dev.of_node = pdev->dev.of_node;
 
        ret = i2c_add_numbered_adapter(&i2c_dev->adapter);
-       if (ret) {
-               dev_err(&pdev->dev, "Failed to add I2C adapter\n");
+       if (ret)
                goto disable_div_clk;
-       }
 
        return 0;
 
@@ -956,6 +962,7 @@ unprepare_fast_clk:
 static int tegra_i2c_remove(struct platform_device *pdev)
 {
        struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
+
        i2c_del_adapter(&i2c_dev->adapter);
 
        if (i2c_dev->is_multimaster_mode)