i2c: designware-baytrail: Add support for cherrytrail
authorHans de Goede <hdegoede@redhat.com>
Fri, 10 Feb 2017 10:27:58 +0000 (11:27 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 2 Mar 2017 14:46:34 +0000 (15:46 +0100)
The cherrytrail punit has the pmic i2c bus access semaphore at a
different register address.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170210102802.20898-9-hdegoede@redhat.com
drivers/i2c/busses/i2c-designware-baytrail.c
drivers/i2c/busses/i2c-designware-core.h
drivers/i2c/busses/i2c-designware-pcidrv.c
drivers/i2c/busses/i2c-designware-platdrv.c

index 8df529c04f8e4181437073b961d8a4a61c92ccd4..3effc9a1778c31eb0b9f683e0fa5cb7ecb305270 100644 (file)
 
 #define SEMAPHORE_TIMEOUT      100
 #define PUNIT_SEMAPHORE                0x7
+#define PUNIT_SEMAPHORE_CHT    0x10e
 #define PUNIT_SEMAPHORE_BIT    BIT(0)
 #define PUNIT_SEMAPHORE_ACQUIRE        BIT(1)
 
 static unsigned long acquired;
 
+static u32 get_sem_addr(struct dw_i2c_dev *dev)
+{
+       if (dev->flags & MODEL_CHERRYTRAIL)
+               return PUNIT_SEMAPHORE_CHT;
+       else
+               return PUNIT_SEMAPHORE;
+}
+
 static int get_sem(struct dw_i2c_dev *dev, u32 *sem)
 {
+       u32 addr = get_sem_addr(dev);
        u32 data;
        int ret;
 
-       ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, &data);
+       ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, addr, &data);
        if (ret) {
                dev_err(dev->dev, "iosf failed to read punit semaphore\n");
                return ret;
@@ -47,7 +57,7 @@ static int get_sem(struct dw_i2c_dev *dev, u32 *sem)
 
 static void reset_semaphore(struct dw_i2c_dev *dev)
 {
-       if (iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE,
+       if (iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, get_sem_addr(dev),
                            0, PUNIT_SEMAPHORE_BIT))
                dev_err(dev->dev, "iosf failed to reset punit semaphore during write\n");
 
@@ -56,6 +66,7 @@ static void reset_semaphore(struct dw_i2c_dev *dev)
 
 static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
 {
+       u32 addr = get_sem_addr(dev);
        u32 sem = PUNIT_SEMAPHORE_ACQUIRE;
        int ret;
        unsigned long start, end;
@@ -76,7 +87,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
        pm_qos_update_request(&dev->pm_qos, 0);
 
        /* host driver writes to side band semaphore register */
-       ret = iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, PUNIT_SEMAPHORE, sem);
+       ret = iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, addr, sem);
        if (ret) {
                dev_err(dev->dev, "iosf punit semaphore request failed\n");
                goto out;
@@ -101,7 +112,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
 out:
        reset_semaphore(dev);
 
-       ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, &sem);
+       ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, addr, &sem);
        if (ret)
                dev_err(dev->dev, "iosf failed to read punit semaphore\n");
        else
index 94a5fd193b404a59161cd293c150758d06c89c8f..a8e74caf8df43636c28f3624c6e1e03703d9d9cb 100644 (file)
@@ -135,6 +135,8 @@ struct dw_i2c_dev {
 #define ACCESS_16BIT           0x00000002
 #define ACCESS_INTR_MASK       0x00000004
 
+#define MODEL_CHERRYTRAIL      0x00000100
+
 extern int i2c_dw_init(struct dw_i2c_dev *dev);
 extern void i2c_dw_disable(struct dw_i2c_dev *dev);
 extern void i2c_dw_disable_int(struct dw_i2c_dev *dev);
index d6423cfac588aa6621c86f788524bfda81cd93d7..ed485b69b449ca6b647f9c8bea30053cc564c315 100644 (file)
@@ -45,6 +45,7 @@ enum dw_pci_ctl_id_t {
        medfield,
        merrifield,
        baytrail,
+       cherrytrail,
        haswell,
 };
 
@@ -63,6 +64,7 @@ struct dw_pci_controller {
        u32 rx_fifo_depth;
        u32 clk_khz;
        u32 functionality;
+       u32 flags;
        struct dw_scl_sda_cfg *scl_sda_cfg;
        int (*setup)(struct pci_dev *pdev, struct dw_pci_controller *c);
 };
@@ -170,6 +172,15 @@ static struct dw_pci_controller dw_pci_controllers[] = {
                .functionality = I2C_FUNC_10BIT_ADDR,
                .scl_sda_cfg = &hsw_config,
        },
+       [cherrytrail] = {
+               .bus_num = -1,
+               .bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
+               .tx_fifo_depth = 32,
+               .rx_fifo_depth = 32,
+               .functionality = I2C_FUNC_10BIT_ADDR,
+               .flags = MODEL_CHERRYTRAIL,
+               .scl_sda_cfg = &byt_config,
+       },
 };
 
 #ifdef CONFIG_PM
@@ -237,6 +248,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
        dev->base = pcim_iomap_table(pdev)[0];
        dev->dev = &pdev->dev;
        dev->irq = pdev->irq;
+       dev->flags |= controller->flags;
 
        if (controller->setup) {
                r = controller->setup(pdev, controller);
@@ -317,13 +329,13 @@ static const struct pci_device_id i2_designware_pci_ids[] = {
        { PCI_VDEVICE(INTEL, 0x9c61), haswell },
        { PCI_VDEVICE(INTEL, 0x9c62), haswell },
        /* Braswell / Cherrytrail */
-       { PCI_VDEVICE(INTEL, 0x22C1), baytrail },
-       { PCI_VDEVICE(INTEL, 0x22C2), baytrail },
-       { PCI_VDEVICE(INTEL, 0x22C3), baytrail },
-       { PCI_VDEVICE(INTEL, 0x22C4), baytrail },
-       { PCI_VDEVICE(INTEL, 0x22C5), baytrail },
-       { PCI_VDEVICE(INTEL, 0x22C6), baytrail },
-       { PCI_VDEVICE(INTEL, 0x22C7), baytrail },
+       { PCI_VDEVICE(INTEL, 0x22C1), cherrytrail },
+       { PCI_VDEVICE(INTEL, 0x22C2), cherrytrail },
+       { PCI_VDEVICE(INTEL, 0x22C3), cherrytrail },
+       { PCI_VDEVICE(INTEL, 0x22C4), cherrytrail },
+       { PCI_VDEVICE(INTEL, 0x22C5), cherrytrail },
+       { PCI_VDEVICE(INTEL, 0x22C6), cherrytrail },
+       { PCI_VDEVICE(INTEL, 0x22C7), cherrytrail },
        { 0,}
 };
 MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids);
index d474db074b1a69a5277081c4f88576efd666f96a..df0ff7d82b497cdaf2073734b00930d541cfd30b 100644 (file)
@@ -123,7 +123,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = {
        { "INT3432", 0 },
        { "INT3433", 0 },
        { "80860F41", 0 },
-       { "808622C1", 0 },
+       { "808622C1", MODEL_CHERRYTRAIL },
        { "AMD0010", ACCESS_INTR_MASK },
        { "AMDI0010", ACCESS_INTR_MASK },
        { "AMDI0510", 0 },