aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/osl.c2
-rw-r--r--drivers/bluetooth/ath3k.c10
-rw-r--r--drivers/bluetooth/btusb.c5
-rw-r--r--drivers/edac/edac_mc.c6
-rw-r--r--drivers/edac/edac_pci_sysfs.c2
-rw-r--r--drivers/firmware/dmi_scan.c2
-rw-r--r--drivers/firmware/efivars.c9
-rw-r--r--drivers/firmware/iscsi_ibft_find.c2
-rw-r--r--drivers/gpio/Kconfig7
-rw-r--r--drivers/gpio/Makefile1
-rw-r--r--drivers/gpio/gpio-palmas.c184
-rw-r--r--drivers/gpu/drm/exynos/Kconfig4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_connector.c33
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dmabuf.c24
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_g2d.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.c9
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.h4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_ipp.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_rotator.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c26
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c121
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c9
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c2
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c24
-rw-r--r--drivers/gpu/drm/radeon/ni.c8
-rw-r--r--drivers/gpu/drm/radeon/r600.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cursor.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c2
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c13
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/input/misc/max8925_onkey.c3
-rw-r--r--drivers/iommu/amd_iommu_init.c34
-rw-r--r--drivers/iommu/intel-iommu.c21
-rw-r--r--drivers/isdn/gigaset/capi.c2
-rw-r--r--drivers/md/dm-raid.c101
-rw-r--r--drivers/md/dm-thin.c13
-rw-r--r--drivers/md/dm.c6
-rw-r--r--drivers/mfd/88pm800.c10
-rw-r--r--drivers/mfd/88pm805.c4
-rw-r--r--drivers/mfd/88pm80x.c22
-rw-r--r--drivers/mfd/Kconfig1
-rw-r--r--drivers/mfd/Makefile2
-rw-r--r--drivers/mfd/ab8500-core.c7
-rw-r--r--drivers/mfd/arizona-core.c62
-rw-r--r--drivers/mfd/arizona-irq.c18
-rw-r--r--drivers/mfd/da9052-i2c.c61
-rw-r--r--drivers/mfd/db8500-prcmu.c30
-rw-r--r--drivers/mfd/lpc_ich.c109
-rw-r--r--drivers/mfd/max77686.c18
-rw-r--r--drivers/mfd/max77693.c34
-rw-r--r--drivers/mfd/max8925-core.c89
-rw-r--r--drivers/mfd/max8925-i2c.c36
-rw-r--r--drivers/mfd/palmas.c14
-rw-r--r--drivers/mfd/pcf50633-core.c5
-rw-r--r--drivers/mfd/rtl8411.c39
-rw-r--r--drivers/mfd/rts5209.c29
-rw-r--r--drivers/mfd/rts5227.c234
-rw-r--r--drivers/mfd/rts5229.c29
-rw-r--r--drivers/mfd/rtsx_pcr.c85
-rw-r--r--drivers/mfd/rtsx_pcr.h4
-rw-r--r--drivers/mfd/tc3589x.c17
-rw-r--r--drivers/mfd/tps6507x.c9
-rw-r--r--drivers/mfd/tps65090.c47
-rw-r--r--drivers/mfd/twl-core.c362
-rw-r--r--drivers/mfd/twl4030-power.c2
-rw-r--r--drivers/mfd/vexpress-config.c8
-rw-r--r--drivers/mfd/vexpress-sysreg.c83
-rw-r--r--drivers/mfd/wm5102-tables.c133
-rw-r--r--drivers/mfd/wm8994-core.c7
-rw-r--r--drivers/mmc/host/rtsx_pci_sdmmc.c30
-rw-r--r--drivers/net/can/c_can/c_can.c4
-rw-r--r--drivers/net/can/pch_can.c2
-rw-r--r--drivers/net/can/ti_hecc.c4
-rw-r--r--drivers/net/ethernet/3com/3c574_cs.c2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c62
-rw-r--r--drivers/net/ethernet/calxeda/xgmac.c4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c17
-rw-r--r--drivers/net/ethernet/intel/ixgbe/Makefile3
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c5
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c11
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c2
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c2
-rw-r--r--drivers/net/ethernet/realtek/r8169.c21
-rw-r--r--drivers/net/hyperv/hyperv_net.h2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c2
-rw-r--r--drivers/net/loopback.c5
-rw-r--r--drivers/net/macvlan.c5
-rw-r--r--drivers/net/phy/icplus.c29
-rw-r--r--drivers/net/phy/marvell.c9
-rw-r--r--drivers/net/tun.c45
-rw-r--r--drivers/net/usb/cdc_mbim.c19
-rw-r--r--drivers/net/usb/cdc_ncm.c31
-rw-r--r--drivers/net/usb/dm9601.c52
-rw-r--r--drivers/net/usb/qmi_wwan.c2
-rw-r--r--drivers/net/usb/usbnet.c4
-rw-r--r--drivers/net/virtio_net.c118
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_calib.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c27
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c54
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c7
-rw-r--r--drivers/net/wireless/iwlegacy/common.c35
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/tx.c2
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c17
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c2
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c14
-rw-r--r--drivers/net/wireless/rtlwifi/Kconfig4
-rw-r--r--drivers/pinctrl/Kconfig1
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-dove.c2
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-kirkwood.c8
-rw-r--r--drivers/pinctrl/pinctrl-exynos5440.c10
-rw-r--r--drivers/pinctrl/pinctrl-mxs.c9
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c2
-rw-r--r--drivers/pinctrl/pinctrl-single.c79
-rw-r--r--drivers/platform/x86/ibm_rtl.c2
-rw-r--r--drivers/platform/x86/samsung-laptop.c4
-rw-r--r--drivers/regulator/dbx500-prcmu.c1
-rw-r--r--drivers/regulator/tps80031-regulator.c2
-rw-r--r--drivers/rtc/Kconfig10
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-palmas.c339
-rw-r--r--drivers/scsi/isci/init.c2
-rw-r--r--drivers/video/backlight/max8925_bl.c31
-rw-r--r--drivers/watchdog/Kconfig12
-rw-r--r--drivers/watchdog/Makefile1
-rw-r--r--drivers/watchdog/ux500_wdt.c171
139 files changed, 2557 insertions, 1168 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 3ff267861541..bd22f8667eed 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -250,7 +250,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
250 return acpi_rsdp; 250 return acpi_rsdp;
251#endif 251#endif
252 252
253 if (efi_enabled) { 253 if (efi_enabled(EFI_CONFIG_TABLES)) {
254 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) 254 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
255 return efi.acpi20; 255 return efi.acpi20;
256 else if (efi.acpi != EFI_INVALID_TABLE_ADDR) 256 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index b00000e8aef6..33c9a44a9678 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -77,10 +77,15 @@ static struct usb_device_id ath3k_table[] = {
77 { USB_DEVICE(0x0CF3, 0x311D) }, 77 { USB_DEVICE(0x0CF3, 0x311D) },
78 { USB_DEVICE(0x13d3, 0x3375) }, 78 { USB_DEVICE(0x13d3, 0x3375) },
79 { USB_DEVICE(0x04CA, 0x3005) }, 79 { USB_DEVICE(0x04CA, 0x3005) },
80 { USB_DEVICE(0x04CA, 0x3006) },
81 { USB_DEVICE(0x04CA, 0x3008) },
80 { USB_DEVICE(0x13d3, 0x3362) }, 82 { USB_DEVICE(0x13d3, 0x3362) },
81 { USB_DEVICE(0x0CF3, 0xE004) }, 83 { USB_DEVICE(0x0CF3, 0xE004) },
82 { USB_DEVICE(0x0930, 0x0219) }, 84 { USB_DEVICE(0x0930, 0x0219) },
83 { USB_DEVICE(0x0489, 0xe057) }, 85 { USB_DEVICE(0x0489, 0xe057) },
86 { USB_DEVICE(0x13d3, 0x3393) },
87 { USB_DEVICE(0x0489, 0xe04e) },
88 { USB_DEVICE(0x0489, 0xe056) },
84 89
85 /* Atheros AR5BBU12 with sflash firmware */ 90 /* Atheros AR5BBU12 with sflash firmware */
86 { USB_DEVICE(0x0489, 0xE02C) }, 91 { USB_DEVICE(0x0489, 0xE02C) },
@@ -104,10 +109,15 @@ static struct usb_device_id ath3k_blist_tbl[] = {
104 { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 }, 109 { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
105 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 110 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
106 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, 111 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
112 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
113 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
107 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, 114 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
108 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 }, 115 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
109 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 116 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
110 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 }, 117 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
118 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
119 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
120 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
111 121
112 /* Atheros AR5BBU22 with sflash firmware */ 122 /* Atheros AR5BBU22 with sflash firmware */
113 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 }, 123 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index a1d4ede5b892..7e351e345476 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -135,10 +135,15 @@ static struct usb_device_id blacklist_table[] = {
135 { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 }, 135 { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
136 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 136 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
137 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, 137 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
138 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
139 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
138 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, 140 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
139 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 }, 141 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
140 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 142 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
141 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 }, 143 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
144 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
145 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
146 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
142 147
143 /* Atheros AR5BBU12 with sflash firmware */ 148 /* Atheros AR5BBU12 with sflash firmware */
144 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, 149 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 281f566a5513..d1e9eb191f2b 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -340,7 +340,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
340 /* 340 /*
341 * Alocate and fill the csrow/channels structs 341 * Alocate and fill the csrow/channels structs
342 */ 342 */
343 mci->csrows = kcalloc(sizeof(*mci->csrows), tot_csrows, GFP_KERNEL); 343 mci->csrows = kcalloc(tot_csrows, sizeof(*mci->csrows), GFP_KERNEL);
344 if (!mci->csrows) 344 if (!mci->csrows)
345 goto error; 345 goto error;
346 for (row = 0; row < tot_csrows; row++) { 346 for (row = 0; row < tot_csrows; row++) {
@@ -351,7 +351,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
351 csr->csrow_idx = row; 351 csr->csrow_idx = row;
352 csr->mci = mci; 352 csr->mci = mci;
353 csr->nr_channels = tot_channels; 353 csr->nr_channels = tot_channels;
354 csr->channels = kcalloc(sizeof(*csr->channels), tot_channels, 354 csr->channels = kcalloc(tot_channels, sizeof(*csr->channels),
355 GFP_KERNEL); 355 GFP_KERNEL);
356 if (!csr->channels) 356 if (!csr->channels)
357 goto error; 357 goto error;
@@ -369,7 +369,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
369 /* 369 /*
370 * Allocate and fill the dimm structs 370 * Allocate and fill the dimm structs
371 */ 371 */
372 mci->dimms = kcalloc(sizeof(*mci->dimms), tot_dimms, GFP_KERNEL); 372 mci->dimms = kcalloc(tot_dimms, sizeof(*mci->dimms), GFP_KERNEL);
373 if (!mci->dimms) 373 if (!mci->dimms)
374 goto error; 374 goto error;
375 375
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index dc6e905ee1a5..0056c4dae9d5 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -256,7 +256,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
256 struct edac_pci_dev_attribute *edac_pci_dev; 256 struct edac_pci_dev_attribute *edac_pci_dev;
257 edac_pci_dev = (struct edac_pci_dev_attribute *)attr; 257 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
258 258
259 if (edac_pci_dev->show) 259 if (edac_pci_dev->store)
260 return edac_pci_dev->store(edac_pci_dev->value, buffer, count); 260 return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
261 return -EIO; 261 return -EIO;
262} 262}
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index fd3ae6290d71..982f1f5f5742 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -471,7 +471,7 @@ void __init dmi_scan_machine(void)
471 char __iomem *p, *q; 471 char __iomem *p, *q;
472 int rc; 472 int rc;
473 473
474 if (efi_enabled) { 474 if (efi_enabled(EFI_CONFIG_TABLES)) {
475 if (efi.smbios == EFI_INVALID_TABLE_ADDR) 475 if (efi.smbios == EFI_INVALID_TABLE_ADDR)
476 goto error; 476 goto error;
477 477
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 7b1c37497c9a..f5596db0cf58 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -674,7 +674,7 @@ static int efi_status_to_err(efi_status_t status)
674 err = -EACCES; 674 err = -EACCES;
675 break; 675 break;
676 case EFI_NOT_FOUND: 676 case EFI_NOT_FOUND:
677 err = -ENOENT; 677 err = -EIO;
678 break; 678 break;
679 default: 679 default:
680 err = -EINVAL; 680 err = -EINVAL;
@@ -793,6 +793,7 @@ static ssize_t efivarfs_file_write(struct file *file,
793 spin_unlock(&efivars->lock); 793 spin_unlock(&efivars->lock);
794 efivar_unregister(var); 794 efivar_unregister(var);
795 drop_nlink(inode); 795 drop_nlink(inode);
796 d_delete(file->f_dentry);
796 dput(file->f_dentry); 797 dput(file->f_dentry);
797 798
798 } else { 799 } else {
@@ -994,7 +995,7 @@ static int efivarfs_unlink(struct inode *dir, struct dentry *dentry)
994 list_del(&var->list); 995 list_del(&var->list);
995 spin_unlock(&efivars->lock); 996 spin_unlock(&efivars->lock);
996 efivar_unregister(var); 997 efivar_unregister(var);
997 drop_nlink(dir); 998 drop_nlink(dentry->d_inode);
998 dput(dentry); 999 dput(dentry);
999 return 0; 1000 return 0;
1000 } 1001 }
@@ -1782,7 +1783,7 @@ efivars_init(void)
1782 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION, 1783 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
1783 EFIVARS_DATE); 1784 EFIVARS_DATE);
1784 1785
1785 if (!efi_enabled) 1786 if (!efi_enabled(EFI_RUNTIME_SERVICES))
1786 return 0; 1787 return 0;
1787 1788
1788 /* For now we'll register the efi directory at /sys/firmware/efi */ 1789 /* For now we'll register the efi directory at /sys/firmware/efi */
@@ -1822,7 +1823,7 @@ err_put:
1822static void __exit 1823static void __exit
1823efivars_exit(void) 1824efivars_exit(void)
1824{ 1825{
1825 if (efi_enabled) { 1826 if (efi_enabled(EFI_RUNTIME_SERVICES)) {
1826 unregister_efivars(&__efivars); 1827 unregister_efivars(&__efivars);
1827 kobject_put(efi_kobj); 1828 kobject_put(efi_kobj);
1828 } 1829 }
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c
index 4da4eb9ae926..2224f1dc074b 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -99,7 +99,7 @@ unsigned long __init find_ibft_region(unsigned long *sizep)
99 /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will 99 /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
100 * only use ACPI for this */ 100 * only use ACPI for this */
101 101
102 if (!efi_enabled) 102 if (!efi_enabled(EFI_BOOT))
103 find_ibft_in_mem(); 103 find_ibft_in_mem();
104 104
105 if (ibft_addr) { 105 if (ibft_addr) {
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 682de754d63f..40a0ec3b7c40 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -663,6 +663,13 @@ config GPIO_AB8500
663 help 663 help
664 Select this to enable the AB8500 IC GPIO driver 664 Select this to enable the AB8500 IC GPIO driver
665 665
666config GPIO_PALMAS
667 bool "TI PALMAS series PMICs GPIO"
668 depends on MFD_PALMAS
669 help
670 Select this option to enable GPIO driver for the TI PALMAS
671 series chip family.
672
666config GPIO_TPS6586X 673config GPIO_TPS6586X
667 bool "TPS6586X GPIO" 674 bool "TPS6586X GPIO"
668 depends on MFD_TPS6586X 675 depends on MFD_TPS6586X
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index c5aebd008dde..8962c5f7b026 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o
69obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o 69obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o
70obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o 70obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o
71obj-$(CONFIG_ARCH_DAVINCI_TNETV107X) += gpio-tnetv107x.o 71obj-$(CONFIG_ARCH_DAVINCI_TNETV107X) += gpio-tnetv107x.o
72obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o
72obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o 73obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o
73obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o 74obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o
74obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o 75obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o
diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
new file mode 100644
index 000000000000..e3a4e56f5a42
--- /dev/null
+++ b/drivers/gpio/gpio-palmas.c
@@ -0,0 +1,184 @@
1/*
2 * TI Palma series PMIC's GPIO driver.
3 *
4 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
5 *
6 * Author: Laxman Dewangan <ldewangan@nvidia.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <linux/gpio.h>
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/mfd/palmas.h>
25#include <linux/of.h>
26#include <linux/of_device.h>
27#include <linux/platform_device.h>
28
29struct palmas_gpio {
30 struct gpio_chip gpio_chip;
31 struct palmas *palmas;
32};
33
34static inline struct palmas_gpio *to_palmas_gpio(struct gpio_chip *chip)
35{
36 return container_of(chip, struct palmas_gpio, gpio_chip);
37}
38
39static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset)
40{
41 struct palmas_gpio *pg = to_palmas_gpio(gc);
42 struct palmas *palmas = pg->palmas;
43 unsigned int val;
44 int ret;
45
46 ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_IN, &val);
47 if (ret < 0) {
48 dev_err(gc->dev, "GPIO_DATA_IN read failed, err = %d\n", ret);
49 return ret;
50 }
51 return !!(val & BIT(offset));
52}
53
54static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset,
55 int value)
56{
57 struct palmas_gpio *pg = to_palmas_gpio(gc);
58 struct palmas *palmas = pg->palmas;
59 int ret;
60
61 if (value)
62 ret = palmas_write(palmas, PALMAS_GPIO_BASE,
63 PALMAS_GPIO_SET_DATA_OUT, BIT(offset));
64 else
65 ret = palmas_write(palmas, PALMAS_GPIO_BASE,
66 PALMAS_GPIO_CLEAR_DATA_OUT, BIT(offset));
67 if (ret < 0)
68 dev_err(gc->dev, "%s write failed, err = %d\n",
69 (value) ? "GPIO_SET_DATA_OUT" : "GPIO_CLEAR_DATA_OUT",
70 ret);
71}
72
73static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset,
74 int value)
75{
76 struct palmas_gpio *pg = to_palmas_gpio(gc);
77 struct palmas *palmas = pg->palmas;
78 int ret;
79
80 /* Set the initial value */
81 palmas_gpio_set(gc, offset, value);
82
83 ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE,
84 PALMAS_GPIO_DATA_DIR, BIT(offset), BIT(offset));
85 if (ret < 0)
86 dev_err(gc->dev, "GPIO_DATA_DIR write failed, err = %d\n", ret);
87 return ret;
88}
89
90static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset)
91{
92 struct palmas_gpio *pg = to_palmas_gpio(gc);
93 struct palmas *palmas = pg->palmas;
94 int ret;
95
96 ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE,
97 PALMAS_GPIO_DATA_DIR, BIT(offset), 0);
98 if (ret < 0)
99 dev_err(gc->dev, "GPIO_DATA_DIR write failed, err = %d\n", ret);
100 return ret;
101}
102
103static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
104{
105 struct palmas_gpio *pg = to_palmas_gpio(gc);
106 struct palmas *palmas = pg->palmas;
107
108 return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset);
109}
110
111static int palmas_gpio_probe(struct platform_device *pdev)
112{
113 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
114 struct palmas_platform_data *palmas_pdata;
115 struct palmas_gpio *palmas_gpio;
116 int ret;
117
118 palmas_gpio = devm_kzalloc(&pdev->dev,
119 sizeof(*palmas_gpio), GFP_KERNEL);
120 if (!palmas_gpio) {
121 dev_err(&pdev->dev, "Could not allocate palmas_gpio\n");
122 return -ENOMEM;
123 }
124
125 palmas_gpio->palmas = palmas;
126 palmas_gpio->gpio_chip.owner = THIS_MODULE;
127 palmas_gpio->gpio_chip.label = dev_name(&pdev->dev);
128 palmas_gpio->gpio_chip.ngpio = 8;
129 palmas_gpio->gpio_chip.can_sleep = 1;
130 palmas_gpio->gpio_chip.direction_input = palmas_gpio_input;
131 palmas_gpio->gpio_chip.direction_output = palmas_gpio_output;
132 palmas_gpio->gpio_chip.to_irq = palmas_gpio_to_irq;
133 palmas_gpio->gpio_chip.set = palmas_gpio_set;
134 palmas_gpio->gpio_chip.get = palmas_gpio_get;
135 palmas_gpio->gpio_chip.dev = &pdev->dev;
136#ifdef CONFIG_OF_GPIO
137 palmas_gpio->gpio_chip.of_node = palmas->dev->of_node;
138#endif
139 palmas_pdata = dev_get_platdata(palmas->dev);
140 if (palmas_pdata && palmas_pdata->gpio_base)
141 palmas_gpio->gpio_chip.base = palmas_pdata->gpio_base;
142 else
143 palmas_gpio->gpio_chip.base = -1;
144
145 ret = gpiochip_add(&palmas_gpio->gpio_chip);
146 if (ret < 0) {
147 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
148 return ret;
149 }
150
151 platform_set_drvdata(pdev, palmas_gpio);
152 return ret;
153}
154
155static int palmas_gpio_remove(struct platform_device *pdev)
156{
157 struct palmas_gpio *palmas_gpio = platform_get_drvdata(pdev);
158
159 return gpiochip_remove(&palmas_gpio->gpio_chip);
160}
161
162static struct platform_driver palmas_gpio_driver = {
163 .driver.name = "palmas-gpio",
164 .driver.owner = THIS_MODULE,
165 .probe = palmas_gpio_probe,
166 .remove = palmas_gpio_remove,
167};
168
169static int __init palmas_gpio_init(void)
170{
171 return platform_driver_register(&palmas_gpio_driver);
172}
173subsys_initcall(palmas_gpio_init);
174
175static void __exit palmas_gpio_exit(void)
176{
177 platform_driver_unregister(&palmas_gpio_driver);
178}
179module_exit(palmas_gpio_exit);
180
181MODULE_ALIAS("platform:palmas-gpio");
182MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
183MODULE_DESCRIPTION("GPIO driver for TI Palmas series PMICs");
184MODULE_LICENSE("GPL v2");
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 1d1f1e5e33f0..046bcda36abe 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -24,7 +24,7 @@ config DRM_EXYNOS_DMABUF
24 24
25config DRM_EXYNOS_FIMD 25config DRM_EXYNOS_FIMD
26 bool "Exynos DRM FIMD" 26 bool "Exynos DRM FIMD"
27 depends on DRM_EXYNOS && !FB_S3C 27 depends on DRM_EXYNOS && !FB_S3C && !ARCH_MULTIPLATFORM
28 help 28 help
29 Choose this option if you want to use Exynos FIMD for DRM. 29 Choose this option if you want to use Exynos FIMD for DRM.
30 30
@@ -48,7 +48,7 @@ config DRM_EXYNOS_G2D
48 48
49config DRM_EXYNOS_IPP 49config DRM_EXYNOS_IPP
50 bool "Exynos DRM IPP" 50 bool "Exynos DRM IPP"
51 depends on DRM_EXYNOS 51 depends on DRM_EXYNOS && !ARCH_MULTIPLATFORM
52 help 52 help
53 Choose this option if you want to use IPP feature for DRM. 53 Choose this option if you want to use IPP feature for DRM.
54 54
diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c
index ab37437bad8a..4c5b6859c9ea 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_connector.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c
@@ -18,7 +18,6 @@
18#include "exynos_drm_drv.h" 18#include "exynos_drm_drv.h"
19#include "exynos_drm_encoder.h" 19#include "exynos_drm_encoder.h"
20 20
21#define MAX_EDID 256
22#define to_exynos_connector(x) container_of(x, struct exynos_drm_connector,\ 21#define to_exynos_connector(x) container_of(x, struct exynos_drm_connector,\
23 drm_connector) 22 drm_connector)
24 23
@@ -96,7 +95,9 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
96 to_exynos_connector(connector); 95 to_exynos_connector(connector);
97 struct exynos_drm_manager *manager = exynos_connector->manager; 96 struct exynos_drm_manager *manager = exynos_connector->manager;
98 struct exynos_drm_display_ops *display_ops = manager->display_ops; 97 struct exynos_drm_display_ops *display_ops = manager->display_ops;
99 unsigned int count; 98 struct edid *edid = NULL;
99 unsigned int count = 0;
100 int ret;
100 101
101 DRM_DEBUG_KMS("%s\n", __FILE__); 102 DRM_DEBUG_KMS("%s\n", __FILE__);
102 103
@@ -114,27 +115,21 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
114 * because lcd panel has only one mode. 115 * because lcd panel has only one mode.
115 */ 116 */
116 if (display_ops->get_edid) { 117 if (display_ops->get_edid) {
117 int ret; 118 edid = display_ops->get_edid(manager->dev, connector);
118 void *edid; 119 if (IS_ERR_OR_NULL(edid)) {
119 120 ret = PTR_ERR(edid);
120 edid = kzalloc(MAX_EDID, GFP_KERNEL); 121 edid = NULL;
121 if (!edid) { 122 DRM_ERROR("Panel operation get_edid failed %d\n", ret);
122 DRM_ERROR("failed to allocate edid\n"); 123 goto out;
123 return 0;
124 } 124 }
125 125
126 ret = display_ops->get_edid(manager->dev, connector, 126 count = drm_add_edid_modes(connector, edid);
127 edid, MAX_EDID); 127 if (count < 0) {
128 if (ret < 0) { 128 DRM_ERROR("Add edid modes failed %d\n", count);
129 DRM_ERROR("failed to get edid data.\n"); 129 goto out;
130 kfree(edid);
131 edid = NULL;
132 return 0;
133 } 130 }
134 131
135 drm_mode_connector_update_edid_property(connector, edid); 132 drm_mode_connector_update_edid_property(connector, edid);
136 count = drm_add_edid_modes(connector, edid);
137 kfree(edid);
138 } else { 133 } else {
139 struct exynos_drm_panel_info *panel; 134 struct exynos_drm_panel_info *panel;
140 struct drm_display_mode *mode = drm_mode_create(connector->dev); 135 struct drm_display_mode *mode = drm_mode_create(connector->dev);
@@ -161,6 +156,8 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
161 count = 1; 156 count = 1;
162 } 157 }
163 158
159out:
160 kfree(edid);
164 return count; 161 return count;
165} 162}
166 163
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index 9df97714b6c0..ba0a3aa78547 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -19,6 +19,7 @@
19struct exynos_drm_dmabuf_attachment { 19struct exynos_drm_dmabuf_attachment {
20 struct sg_table sgt; 20 struct sg_table sgt;
21 enum dma_data_direction dir; 21 enum dma_data_direction dir;
22 bool is_mapped;
22}; 23};
23 24
24static int exynos_gem_attach_dma_buf(struct dma_buf *dmabuf, 25static int exynos_gem_attach_dma_buf(struct dma_buf *dmabuf,
@@ -72,17 +73,10 @@ static struct sg_table *
72 73
73 DRM_DEBUG_PRIME("%s\n", __FILE__); 74 DRM_DEBUG_PRIME("%s\n", __FILE__);
74 75
75 if (WARN_ON(dir == DMA_NONE))
76 return ERR_PTR(-EINVAL);
77
78 /* just return current sgt if already requested. */ 76 /* just return current sgt if already requested. */
79 if (exynos_attach->dir == dir) 77 if (exynos_attach->dir == dir && exynos_attach->is_mapped)
80 return &exynos_attach->sgt; 78 return &exynos_attach->sgt;
81 79
82 /* reattaching is not allowed. */
83 if (WARN_ON(exynos_attach->dir != DMA_NONE))
84 return ERR_PTR(-EBUSY);
85
86 buf = gem_obj->buffer; 80 buf = gem_obj->buffer;
87 if (!buf) { 81 if (!buf) {
88 DRM_ERROR("buffer is null.\n"); 82 DRM_ERROR("buffer is null.\n");
@@ -107,13 +101,17 @@ static struct sg_table *
107 wr = sg_next(wr); 101 wr = sg_next(wr);
108 } 102 }
109 103
110 nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir); 104 if (dir != DMA_NONE) {
111 if (!nents) { 105 nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir);
112 DRM_ERROR("failed to map sgl with iommu.\n"); 106 if (!nents) {
113 sgt = ERR_PTR(-EIO); 107 DRM_ERROR("failed to map sgl with iommu.\n");
114 goto err_unlock; 108 sg_free_table(sgt);
109 sgt = ERR_PTR(-EIO);
110 goto err_unlock;
111 }
115 } 112 }
116 113
114 exynos_attach->is_mapped = true;
117 exynos_attach->dir = dir; 115 exynos_attach->dir = dir;
118 attach->priv = exynos_attach; 116 attach->priv = exynos_attach;
119 117
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index b9e51bc09e81..4606fac7241a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -148,8 +148,8 @@ struct exynos_drm_overlay {
148struct exynos_drm_display_ops { 148struct exynos_drm_display_ops {
149 enum exynos_drm_output_type type; 149 enum exynos_drm_output_type type;
150 bool (*is_connected)(struct device *dev); 150 bool (*is_connected)(struct device *dev);
151 int (*get_edid)(struct device *dev, struct drm_connector *connector, 151 struct edid *(*get_edid)(struct device *dev,
152 u8 *edid, int len); 152 struct drm_connector *connector);
153 void *(*get_panel)(struct device *dev); 153 void *(*get_panel)(struct device *dev);
154 int (*check_timing)(struct device *dev, void *timing); 154 int (*check_timing)(struct device *dev, void *timing);
155 int (*power_on)(struct device *dev, int mode); 155 int (*power_on)(struct device *dev, int mode);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index 36c3905536a6..9a4c08e7453c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -324,7 +324,7 @@ out:
324 g2d_userptr = NULL; 324 g2d_userptr = NULL;
325} 325}
326 326
327dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev, 327static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
328 unsigned long userptr, 328 unsigned long userptr,
329 unsigned long size, 329 unsigned long size,
330 struct drm_file *filp, 330 struct drm_file *filp,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
index 850e9950b7da..28644539b305 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
@@ -108,18 +108,17 @@ static bool drm_hdmi_is_connected(struct device *dev)
108 return false; 108 return false;
109} 109}
110 110
111static int drm_hdmi_get_edid(struct device *dev, 111static struct edid *drm_hdmi_get_edid(struct device *dev,
112 struct drm_connector *connector, u8 *edid, int len) 112 struct drm_connector *connector)
113{ 113{
114 struct drm_hdmi_context *ctx = to_context(dev); 114 struct drm_hdmi_context *ctx = to_context(dev);
115 115
116 DRM_DEBUG_KMS("%s\n", __FILE__); 116 DRM_DEBUG_KMS("%s\n", __FILE__);
117 117
118 if (hdmi_ops && hdmi_ops->get_edid) 118 if (hdmi_ops && hdmi_ops->get_edid)
119 return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector, edid, 119 return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector);
120 len);
121 120
122 return 0; 121 return NULL;
123} 122}
124 123
125static int drm_hdmi_check_timing(struct device *dev, void *timing) 124static int drm_hdmi_check_timing(struct device *dev, void *timing)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
index 784a7e9a766c..d80516fc9ed7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
@@ -30,8 +30,8 @@ struct exynos_drm_hdmi_context {
30struct exynos_hdmi_ops { 30struct exynos_hdmi_ops {
31 /* display */ 31 /* display */
32 bool (*is_connected)(void *ctx); 32 bool (*is_connected)(void *ctx);
33 int (*get_edid)(void *ctx, struct drm_connector *connector, 33 struct edid *(*get_edid)(void *ctx,
34 u8 *edid, int len); 34 struct drm_connector *connector);
35 int (*check_timing)(void *ctx, void *timing); 35 int (*check_timing)(void *ctx, void *timing);
36 int (*power_on)(void *ctx, int mode); 36 int (*power_on)(void *ctx, int mode);
37 37
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 0bda96454a02..1a556354e92f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -869,7 +869,7 @@ static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node,
869 } 869 }
870} 870}
871 871
872void ipp_handle_cmd_work(struct device *dev, 872static void ipp_handle_cmd_work(struct device *dev,
873 struct exynos_drm_ippdrv *ippdrv, 873 struct exynos_drm_ippdrv *ippdrv,
874 struct drm_exynos_ipp_cmd_work *cmd_work, 874 struct drm_exynos_ipp_cmd_work *cmd_work,
875 struct drm_exynos_ipp_cmd_node *c_node) 875 struct drm_exynos_ipp_cmd_node *c_node)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index e9e83ef688f0..f976e29def6e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -734,7 +734,7 @@ static int rotator_remove(struct platform_device *pdev)
734 return 0; 734 return 0;
735} 735}
736 736
737struct rot_limit_table rot_limit_tbl = { 737static struct rot_limit_table rot_limit_tbl = {
738 .ycbcr420_2p = { 738 .ycbcr420_2p = {
739 .min_w = 32, 739 .min_w = 32,
740 .min_h = 32, 740 .min_h = 32,
@@ -751,7 +751,7 @@ struct rot_limit_table rot_limit_tbl = {
751 }, 751 },
752}; 752};
753 753
754struct platform_device_id rotator_driver_ids[] = { 754static struct platform_device_id rotator_driver_ids[] = {
755 { 755 {
756 .name = "exynos-rot", 756 .name = "exynos-rot",
757 .driver_data = (unsigned long)&rot_limit_tbl, 757 .driver_data = (unsigned long)&rot_limit_tbl,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index d0ca3c4e06c6..13ccbd4bcfaa 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -98,10 +98,12 @@ static bool vidi_display_is_connected(struct device *dev)
98 return ctx->connected ? true : false; 98 return ctx->connected ? true : false;
99} 99}
100 100
101static int vidi_get_edid(struct device *dev, struct drm_connector *connector, 101static struct edid *vidi_get_edid(struct device *dev,
102 u8 *edid, int len) 102 struct drm_connector *connector)
103{ 103{
104 struct vidi_context *ctx = get_vidi_context(dev); 104 struct vidi_context *ctx = get_vidi_context(dev);
105 struct edid *edid;
106 int edid_len;
105 107
106 DRM_DEBUG_KMS("%s\n", __FILE__); 108 DRM_DEBUG_KMS("%s\n", __FILE__);
107 109
@@ -111,13 +113,18 @@ static int vidi_get_edid(struct device *dev, struct drm_connector *connector,
111 */ 113 */
112 if (!ctx->raw_edid) { 114 if (!ctx->raw_edid) {
113 DRM_DEBUG_KMS("raw_edid is null.\n"); 115 DRM_DEBUG_KMS("raw_edid is null.\n");
114 return -EFAULT; 116 return ERR_PTR(-EFAULT);
115 } 117 }
116 118
117 memcpy(edid, ctx->raw_edid, min((1 + ctx->raw_edid->extensions) 119 edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH;
118 * EDID_LENGTH, len)); 120 edid = kzalloc(edid_len, GFP_KERNEL);
121 if (!edid) {
122 DRM_DEBUG_KMS("failed to allocate edid\n");
123 return ERR_PTR(-ENOMEM);
124 }
119 125
120 return 0; 126 memcpy(edid, ctx->raw_edid, edid_len);
127 return edid;
121} 128}
122 129
123static void *vidi_get_panel(struct device *dev) 130static void *vidi_get_panel(struct device *dev)
@@ -514,7 +521,6 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
514 struct exynos_drm_manager *manager; 521 struct exynos_drm_manager *manager;
515 struct exynos_drm_display_ops *display_ops; 522 struct exynos_drm_display_ops *display_ops;
516 struct drm_exynos_vidi_connection *vidi = data; 523 struct drm_exynos_vidi_connection *vidi = data;
517 struct edid *raw_edid;
518 int edid_len; 524 int edid_len;
519 525
520 DRM_DEBUG_KMS("%s\n", __FILE__); 526 DRM_DEBUG_KMS("%s\n", __FILE__);
@@ -551,11 +557,11 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
551 } 557 }
552 558
553 if (vidi->connection) { 559 if (vidi->connection) {
554 if (!vidi->edid) { 560 struct edid *raw_edid = (struct edid *)(uint32_t)vidi->edid;
555 DRM_DEBUG_KMS("edid data is null.\n"); 561 if (!drm_edid_is_valid(raw_edid)) {
562 DRM_DEBUG_KMS("edid data is invalid.\n");
556 return -EINVAL; 563 return -EINVAL;
557 } 564 }
558 raw_edid = (struct edid *)(uint32_t)vidi->edid;
559 edid_len = (1 + raw_edid->extensions) * EDID_LENGTH; 565 edid_len = (1 + raw_edid->extensions) * EDID_LENGTH;
560 ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL); 566 ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL);
561 if (!ctx->raw_edid) { 567 if (!ctx->raw_edid) {
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 41ff79d8ac8e..fbab3c468603 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -34,7 +34,6 @@
34#include <linux/regulator/consumer.h> 34#include <linux/regulator/consumer.h>
35#include <linux/io.h> 35#include <linux/io.h>
36#include <linux/of_gpio.h> 36#include <linux/of_gpio.h>
37#include <plat/gpio-cfg.h>
38 37
39#include <drm/exynos_drm.h> 38#include <drm/exynos_drm.h>
40 39
@@ -98,8 +97,7 @@ struct hdmi_context {
98 97
99 void __iomem *regs; 98 void __iomem *regs;
100 void *parent_ctx; 99 void *parent_ctx;
101 int external_irq; 100 int irq;
102 int internal_irq;
103 101
104 struct i2c_client *ddc_port; 102 struct i2c_client *ddc_port;
105 struct i2c_client *hdmiphy_port; 103 struct i2c_client *hdmiphy_port;
@@ -1391,8 +1389,7 @@ static bool hdmi_is_connected(void *ctx)
1391 return hdata->hpd; 1389 return hdata->hpd;
1392} 1390}
1393 1391
1394static int hdmi_get_edid(void *ctx, struct drm_connector *connector, 1392static struct edid *hdmi_get_edid(void *ctx, struct drm_connector *connector)
1395 u8 *edid, int len)
1396{ 1393{
1397 struct edid *raw_edid; 1394 struct edid *raw_edid;
1398 struct hdmi_context *hdata = ctx; 1395 struct hdmi_context *hdata = ctx;
@@ -1400,22 +1397,18 @@ static int hdmi_get_edid(void *ctx, struct drm_connector *connector,
1400 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1397 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1401 1398
1402 if (!hdata->ddc_port) 1399 if (!hdata->ddc_port)
1403 return -ENODEV; 1400 return ERR_PTR(-ENODEV);
1404 1401
1405 raw_edid = drm_get_edid(connector, hdata->ddc_port->adapter); 1402 raw_edid = drm_get_edid(connector, hdata->ddc_port->adapter);
1406 if (raw_edid) { 1403 if (!raw_edid)
1407 hdata->dvi_mode = !drm_detect_hdmi_monitor(raw_edid); 1404 return ERR_PTR(-ENODEV);
1408 memcpy(edid, raw_edid, min((1 + raw_edid->extensions)
1409 * EDID_LENGTH, len));
1410 DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n",
1411 (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"),
1412 raw_edid->width_cm, raw_edid->height_cm);
1413 kfree(raw_edid);
1414 } else {
1415 return -ENODEV;
1416 }
1417 1405
1418 return 0; 1406 hdata->dvi_mode = !drm_detect_hdmi_monitor(raw_edid);
1407 DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n",
1408 (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"),
1409 raw_edid->width_cm, raw_edid->height_cm);
1410
1411 return raw_edid;
1419} 1412}
1420 1413
1421static int hdmi_v13_check_timing(struct fb_videomode *check_timing) 1414static int hdmi_v13_check_timing(struct fb_videomode *check_timing)
@@ -1652,16 +1645,16 @@ static void hdmi_conf_reset(struct hdmi_context *hdata)
1652 1645
1653 /* resetting HDMI core */ 1646 /* resetting HDMI core */
1654 hdmi_reg_writemask(hdata, reg, 0, HDMI_CORE_SW_RSTOUT); 1647 hdmi_reg_writemask(hdata, reg, 0, HDMI_CORE_SW_RSTOUT);
1655 mdelay(10); 1648 usleep_range(10000, 12000);
1656 hdmi_reg_writemask(hdata, reg, ~0, HDMI_CORE_SW_RSTOUT); 1649 hdmi_reg_writemask(hdata, reg, ~0, HDMI_CORE_SW_RSTOUT);
1657 mdelay(10); 1650 usleep_range(10000, 12000);
1658} 1651}
1659 1652
1660static void hdmi_conf_init(struct hdmi_context *hdata) 1653static void hdmi_conf_init(struct hdmi_context *hdata)
1661{ 1654{
1662 struct hdmi_infoframe infoframe; 1655 struct hdmi_infoframe infoframe;
1663 1656
1664 /* disable HPD interrupts */ 1657 /* disable HPD interrupts from HDMI IP block, use GPIO instead */
1665 hdmi_reg_writemask(hdata, HDMI_INTC_CON, 0, HDMI_INTC_EN_GLOBAL | 1658 hdmi_reg_writemask(hdata, HDMI_INTC_CON, 0, HDMI_INTC_EN_GLOBAL |
1666 HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG); 1659 HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG);
1667 1660
@@ -1779,7 +1772,7 @@ static void hdmi_v13_timing_apply(struct hdmi_context *hdata)
1779 u32 val = hdmi_reg_read(hdata, HDMI_V13_PHY_STATUS); 1772 u32 val = hdmi_reg_read(hdata, HDMI_V13_PHY_STATUS);
1780 if (val & HDMI_PHY_STATUS_READY) 1773 if (val & HDMI_PHY_STATUS_READY)
1781 break; 1774 break;
1782 mdelay(1); 1775 usleep_range(1000, 2000);
1783 } 1776 }
1784 /* steady state not achieved */ 1777 /* steady state not achieved */
1785 if (tries == 0) { 1778 if (tries == 0) {
@@ -1946,7 +1939,7 @@ static void hdmi_v14_timing_apply(struct hdmi_context *hdata)
1946 u32 val = hdmi_reg_read(hdata, HDMI_PHY_STATUS_0); 1939 u32 val = hdmi_reg_read(hdata, HDMI_PHY_STATUS_0);
1947 if (val & HDMI_PHY_STATUS_READY) 1940 if (val & HDMI_PHY_STATUS_READY)
1948 break; 1941 break;
1949 mdelay(1); 1942 usleep_range(1000, 2000);
1950 } 1943 }
1951 /* steady state not achieved */ 1944 /* steady state not achieved */
1952 if (tries == 0) { 1945 if (tries == 0) {
@@ -1998,9 +1991,9 @@ static void hdmiphy_conf_reset(struct hdmi_context *hdata)
1998 1991
1999 /* reset hdmiphy */ 1992 /* reset hdmiphy */
2000 hdmi_reg_writemask(hdata, reg, ~0, HDMI_PHY_SW_RSTOUT); 1993 hdmi_reg_writemask(hdata, reg, ~0, HDMI_PHY_SW_RSTOUT);
2001 mdelay(10); 1994 usleep_range(10000, 12000);
2002 hdmi_reg_writemask(hdata, reg, 0, HDMI_PHY_SW_RSTOUT); 1995 hdmi_reg_writemask(hdata, reg, 0, HDMI_PHY_SW_RSTOUT);
2003 mdelay(10); 1996 usleep_range(10000, 12000);
2004} 1997}
2005 1998
2006static void hdmiphy_poweron(struct hdmi_context *hdata) 1999static void hdmiphy_poweron(struct hdmi_context *hdata)
@@ -2048,7 +2041,7 @@ static void hdmiphy_conf_apply(struct hdmi_context *hdata)
2048 return; 2041 return;
2049 } 2042 }
2050 2043
2051 mdelay(10); 2044 usleep_range(10000, 12000);
2052 2045
2053 /* operation mode */ 2046 /* operation mode */
2054 operation[0] = 0x1f; 2047 operation[0] = 0x1f;
@@ -2170,6 +2163,13 @@ static void hdmi_commit(void *ctx)
2170 2163
2171 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 2164 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
2172 2165
2166 mutex_lock(&hdata->hdmi_mutex);
2167 if (!hdata->powered) {
2168 mutex_unlock(&hdata->hdmi_mutex);
2169 return;
2170 }
2171 mutex_unlock(&hdata->hdmi_mutex);
2172
2173 hdmi_conf_apply(hdata); 2173 hdmi_conf_apply(hdata);
2174} 2174}
2175 2175
@@ -2265,7 +2265,7 @@ static struct exynos_hdmi_ops hdmi_ops = {
2265 .dpms = hdmi_dpms, 2265 .dpms = hdmi_dpms,
2266}; 2266};
2267 2267
2268static irqreturn_t hdmi_external_irq_thread(int irq, void *arg) 2268static irqreturn_t hdmi_irq_thread(int irq, void *arg)
2269{ 2269{
2270 struct exynos_drm_hdmi_context *ctx = arg; 2270 struct exynos_drm_hdmi_context *ctx = arg;
2271 struct hdmi_context *hdata = ctx->ctx; 2271 struct hdmi_context *hdata = ctx->ctx;
@@ -2280,31 +2280,6 @@ static irqreturn_t hdmi_external_irq_thread(int irq, void *arg)
2280 return IRQ_HANDLED; 2280 return IRQ_HANDLED;
2281} 2281}
2282 2282
2283static irqreturn_t hdmi_internal_irq_thread(int irq, void *arg)
2284{
2285 struct exynos_drm_hdmi_context *ctx = arg;
2286 struct hdmi_context *hdata = ctx->ctx;
2287 u32 intc_flag;
2288
2289 intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG);
2290 /* clearing flags for HPD plug/unplug */
2291 if (intc_flag & HDMI_INTC_FLAG_HPD_UNPLUG) {
2292 DRM_DEBUG_KMS("unplugged\n");
2293 hdmi_reg_writemask(hdata, HDMI_INTC_FLAG, ~0,
2294 HDMI_INTC_FLAG_HPD_UNPLUG);
2295 }
2296 if (intc_flag & HDMI_INTC_FLAG_HPD_PLUG) {
2297 DRM_DEBUG_KMS("plugged\n");
2298 hdmi_reg_writemask(hdata, HDMI_INTC_FLAG, ~0,
2299 HDMI_INTC_FLAG_HPD_PLUG);
2300 }
2301
2302 if (ctx->drm_dev)
2303 drm_helper_hpd_irq_event(ctx->drm_dev);
2304
2305 return IRQ_HANDLED;
2306}
2307
2308static int hdmi_resources_init(struct hdmi_context *hdata) 2283static int hdmi_resources_init(struct hdmi_context *hdata)
2309{ 2284{
2310 struct device *dev = hdata->dev; 2285 struct device *dev = hdata->dev;
@@ -2555,39 +2530,24 @@ static int hdmi_probe(struct platform_device *pdev)
2555 2530
2556 hdata->hdmiphy_port = hdmi_hdmiphy; 2531 hdata->hdmiphy_port = hdmi_hdmiphy;
2557 2532
2558 hdata->external_irq = gpio_to_irq(hdata->hpd_gpio); 2533 hdata->irq = gpio_to_irq(hdata->hpd_gpio);
2559 if (hdata->external_irq < 0) { 2534 if (hdata->irq < 0) {
2560 DRM_ERROR("failed to get GPIO external irq\n"); 2535 DRM_ERROR("failed to get GPIO irq\n");
2561 ret = hdata->external_irq; 2536 ret = hdata->irq;
2562 goto err_hdmiphy;
2563 }
2564
2565 hdata->internal_irq = platform_get_irq(pdev, 0);
2566 if (hdata->internal_irq < 0) {
2567 DRM_ERROR("failed to get platform internal irq\n");
2568 ret = hdata->internal_irq;
2569 goto err_hdmiphy; 2537 goto err_hdmiphy;
2570 } 2538 }
2571 2539
2572 hdata->hpd = gpio_get_value(hdata->hpd_gpio); 2540 hdata->hpd = gpio_get_value(hdata->hpd_gpio);
2573 2541
2574 ret = request_threaded_irq(hdata->external_irq, NULL, 2542 ret = request_threaded_irq(hdata->irq, NULL,
2575 hdmi_external_irq_thread, IRQF_TRIGGER_RISING | 2543 hdmi_irq_thread, IRQF_TRIGGER_RISING |
2576 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 2544 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
2577 "hdmi_external", drm_hdmi_ctx); 2545 "hdmi", drm_hdmi_ctx);
2578 if (ret) { 2546 if (ret) {
2579 DRM_ERROR("failed to register hdmi external interrupt\n"); 2547 DRM_ERROR("failed to register hdmi interrupt\n");
2580 goto err_hdmiphy; 2548 goto err_hdmiphy;
2581 } 2549 }
2582 2550
2583 ret = request_threaded_irq(hdata->internal_irq, NULL,
2584 hdmi_internal_irq_thread, IRQF_ONESHOT,
2585 "hdmi_internal", drm_hdmi_ctx);
2586 if (ret) {
2587 DRM_ERROR("failed to register hdmi internal interrupt\n");
2588 goto err_free_irq;
2589 }
2590
2591 /* Attach HDMI Driver to common hdmi. */ 2551 /* Attach HDMI Driver to common hdmi. */
2592 exynos_hdmi_drv_attach(drm_hdmi_ctx); 2552 exynos_hdmi_drv_attach(drm_hdmi_ctx);
2593 2553
@@ -2598,8 +2558,6 @@ static int hdmi_probe(struct platform_device *pdev)
2598 2558
2599 return 0; 2559 return 0;
2600 2560
2601err_free_irq:
2602 free_irq(hdata->external_irq, drm_hdmi_ctx);
2603err_hdmiphy: 2561err_hdmiphy:
2604 i2c_del_driver(&hdmiphy_driver); 2562 i2c_del_driver(&hdmiphy_driver);
2605err_ddc: 2563err_ddc:
@@ -2617,8 +2575,7 @@ static int hdmi_remove(struct platform_device *pdev)
2617 2575
2618 pm_runtime_disable(dev); 2576 pm_runtime_disable(dev);
2619 2577
2620 free_irq(hdata->internal_irq, hdata); 2578 free_irq(hdata->irq, hdata);
2621 free_irq(hdata->external_irq, hdata);
2622 2579
2623 2580
2624 /* hdmiphy i2c driver */ 2581 /* hdmiphy i2c driver */
@@ -2637,8 +2594,7 @@ static int hdmi_suspend(struct device *dev)
2637 2594
2638 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 2595 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
2639 2596
2640 disable_irq(hdata->internal_irq); 2597 disable_irq(hdata->irq);
2641 disable_irq(hdata->external_irq);
2642 2598
2643 hdata->hpd = false; 2599 hdata->hpd = false;
2644 if (ctx->drm_dev) 2600 if (ctx->drm_dev)
@@ -2663,8 +2619,7 @@ static int hdmi_resume(struct device *dev)
2663 2619
2664 hdata->hpd = gpio_get_value(hdata->hpd_gpio); 2620 hdata->hpd = gpio_get_value(hdata->hpd_gpio);
2665 2621
2666 enable_irq(hdata->external_irq); 2622 enable_irq(hdata->irq);
2667 enable_irq(hdata->internal_irq);
2668 2623
2669 if (!pm_runtime_suspended(dev)) { 2624 if (!pm_runtime_suspended(dev)) {
2670 DRM_DEBUG_KMS("%s : Already resumed\n", __func__); 2625 DRM_DEBUG_KMS("%s : Already resumed\n", __func__);
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index c187ea33b748..c414584bfbae 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -600,7 +600,7 @@ static void vp_win_reset(struct mixer_context *ctx)
600 /* waiting until VP_SRESET_PROCESSING is 0 */ 600 /* waiting until VP_SRESET_PROCESSING is 0 */
601 if (~vp_reg_read(res, VP_SRESET) & VP_SRESET_PROCESSING) 601 if (~vp_reg_read(res, VP_SRESET) & VP_SRESET_PROCESSING)
602 break; 602 break;
603 mdelay(10); 603 usleep_range(10000, 12000);
604 } 604 }
605 WARN(tries == 0, "failed to reset Video Processor\n"); 605 WARN(tries == 0, "failed to reset Video Processor\n");
606} 606}
@@ -776,6 +776,13 @@ static void mixer_win_commit(void *ctx, int win)
776 776
777 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win); 777 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
778 778
779 mutex_lock(&mixer_ctx->mixer_mutex);
780 if (!mixer_ctx->powered) {
781 mutex_unlock(&mixer_ctx->mixer_mutex);
782 return;
783 }
784 mutex_unlock(&mixer_ctx->mixer_mutex);
785
779 if (win > 1 && mixer_ctx->vp_enabled) 786 if (win > 1 && mixer_ctx->vp_enabled)
780 vp_video_buffer(mixer_ctx, win); 787 vp_video_buffer(mixer_ctx, win);
781 else 788 else
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 7944d301518a..9d4a2c2adf0e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -30,6 +30,7 @@
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/export.h> 32#include <linux/export.h>
33#include <generated/utsrelease.h>
33#include <drm/drmP.h> 34#include <drm/drmP.h>
34#include "intel_drv.h" 35#include "intel_drv.h"
35#include "intel_ringbuffer.h" 36#include "intel_ringbuffer.h"
@@ -690,6 +691,7 @@ static int i915_error_state(struct seq_file *m, void *unused)
690 691
691 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec, 692 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
692 error->time.tv_usec); 693 error->time.tv_usec);
694 seq_printf(m, "Kernel: " UTS_RELEASE);
693 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device); 695 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device);
694 seq_printf(m, "EIR: 0x%08x\n", error->eir); 696 seq_printf(m, "EIR: 0x%08x\n", error->eir);
695 seq_printf(m, "IER: 0x%08x\n", error->ier); 697 seq_printf(m, "IER: 0x%08x\n", error->ier);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index b401788e1791..59afb7eb6db6 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -533,6 +533,7 @@
533#define MI_MODE 0x0209c 533#define MI_MODE 0x0209c
534# define VS_TIMER_DISPATCH (1 << 6) 534# define VS_TIMER_DISPATCH (1 << 6)
535# define MI_FLUSH_ENABLE (1 << 12) 535# define MI_FLUSH_ENABLE (1 << 12)
536# define ASYNC_FLIP_PERF_DISABLE (1 << 14)
536 537
537#define GEN6_GT_MODE 0x20d0 538#define GEN6_GT_MODE 0x20d0
538#define GEN6_GT_MODE_HI (1 << 9) 539#define GEN6_GT_MODE_HI (1 << 9)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index ae253e04c391..42ff97d667d2 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -505,13 +505,25 @@ static int init_render_ring(struct intel_ring_buffer *ring)
505 struct drm_i915_private *dev_priv = dev->dev_private; 505 struct drm_i915_private *dev_priv = dev->dev_private;
506 int ret = init_ring_common(ring); 506 int ret = init_ring_common(ring);
507 507
508 if (INTEL_INFO(dev)->gen > 3) { 508 if (INTEL_INFO(dev)->gen > 3)
509 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(VS_TIMER_DISPATCH)); 509 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(VS_TIMER_DISPATCH));
510 if (IS_GEN7(dev)) 510
511 I915_WRITE(GFX_MODE_GEN7, 511 /* We need to disable the AsyncFlip performance optimisations in order
512 _MASKED_BIT_DISABLE(GFX_TLB_INVALIDATE_ALWAYS) | 512 * to use MI_WAIT_FOR_EVENT within the CS. It should already be
513 _MASKED_BIT_ENABLE(GFX_REPLAY_MODE)); 513 * programmed to '1' on all products.
514 } 514 */
515 if (INTEL_INFO(dev)->gen >= 6)
516 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(ASYNC_FLIP_PERF_DISABLE));
517
518 /* Required for the hardware to program scanline values for waiting */
519 if (INTEL_INFO(dev)->gen == 6)
520 I915_WRITE(GFX_MODE,
521 _MASKED_BIT_ENABLE(GFX_TLB_INVALIDATE_ALWAYS));
522
523 if (IS_GEN7(dev))
524 I915_WRITE(GFX_MODE_GEN7,
525 _MASKED_BIT_DISABLE(GFX_TLB_INVALIDATE_ALWAYS) |
526 _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
515 527
516 if (INTEL_INFO(dev)->gen >= 5) { 528 if (INTEL_INFO(dev)->gen >= 5) {
517 ret = init_pipe_control(ring); 529 ret = init_pipe_control(ring);
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 59acabb45c9b..835992d8d067 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1216,7 +1216,7 @@ void cayman_dma_stop(struct radeon_device *rdev)
1216int cayman_dma_resume(struct radeon_device *rdev) 1216int cayman_dma_resume(struct radeon_device *rdev)
1217{ 1217{
1218 struct radeon_ring *ring; 1218 struct radeon_ring *ring;
1219 u32 rb_cntl, dma_cntl; 1219 u32 rb_cntl, dma_cntl, ib_cntl;
1220 u32 rb_bufsz; 1220 u32 rb_bufsz;
1221 u32 reg_offset, wb_offset; 1221 u32 reg_offset, wb_offset;
1222 int i, r; 1222 int i, r;
@@ -1265,7 +1265,11 @@ int cayman_dma_resume(struct radeon_device *rdev)
1265 WREG32(DMA_RB_BASE + reg_offset, ring->gpu_addr >> 8); 1265 WREG32(DMA_RB_BASE + reg_offset, ring->gpu_addr >> 8);
1266 1266
1267 /* enable DMA IBs */ 1267 /* enable DMA IBs */
1268 WREG32(DMA_IB_CNTL + reg_offset, DMA_IB_ENABLE | CMD_VMID_FORCE); 1268 ib_cntl = DMA_IB_ENABLE | CMD_VMID_FORCE;
1269#ifdef __BIG_ENDIAN
1270 ib_cntl |= DMA_IB_SWAP_ENABLE;
1271#endif
1272 WREG32(DMA_IB_CNTL + reg_offset, ib_cntl);
1269 1273
1270 dma_cntl = RREG32(DMA_CNTL + reg_offset); 1274 dma_cntl = RREG32(DMA_CNTL + reg_offset);
1271 dma_cntl &= ~CTXEMPTY_INT_ENABLE; 1275 dma_cntl &= ~CTXEMPTY_INT_ENABLE;
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 3cb9d6089373..bc2540b17c5e 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2313,7 +2313,7 @@ void r600_dma_stop(struct radeon_device *rdev)
2313int r600_dma_resume(struct radeon_device *rdev) 2313int r600_dma_resume(struct radeon_device *rdev)
2314{ 2314{
2315 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; 2315 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX];
2316 u32 rb_cntl, dma_cntl; 2316 u32 rb_cntl, dma_cntl, ib_cntl;
2317 u32 rb_bufsz; 2317 u32 rb_bufsz;
2318 int r; 2318 int r;
2319 2319
@@ -2353,7 +2353,11 @@ int r600_dma_resume(struct radeon_device *rdev)
2353 WREG32(DMA_RB_BASE, ring->gpu_addr >> 8); 2353 WREG32(DMA_RB_BASE, ring->gpu_addr >> 8);
2354 2354
2355 /* enable DMA IBs */ 2355 /* enable DMA IBs */
2356 WREG32(DMA_IB_CNTL, DMA_IB_ENABLE); 2356 ib_cntl = DMA_IB_ENABLE;
2357#ifdef __BIG_ENDIAN
2358 ib_cntl |= DMA_IB_SWAP_ENABLE;
2359#endif
2360 WREG32(DMA_IB_CNTL, ib_cntl);
2357 2361
2358 dma_cntl = RREG32(DMA_CNTL); 2362 dma_cntl = RREG32(DMA_CNTL);
2359 dma_cntl &= ~CTXEMPTY_INT_ENABLE; 2363 dma_cntl &= ~CTXEMPTY_INT_ENABLE;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 469661fd1903..5407459e56d2 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -286,6 +286,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
286 p->chunks[p->chunk_ib_idx].kpage[1] == NULL) { 286 p->chunks[p->chunk_ib_idx].kpage[1] == NULL) {
287 kfree(p->chunks[p->chunk_ib_idx].kpage[0]); 287 kfree(p->chunks[p->chunk_ib_idx].kpage[0]);
288 kfree(p->chunks[p->chunk_ib_idx].kpage[1]); 288 kfree(p->chunks[p->chunk_ib_idx].kpage[1]);
289 p->chunks[p->chunk_ib_idx].kpage[0] = NULL;
290 p->chunks[p->chunk_ib_idx].kpage[1] = NULL;
289 return -ENOMEM; 291 return -ENOMEM;
290 } 292 }
291 } 293 }
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index ad6df625e8b8..0d67674b64b1 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -241,7 +241,8 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
241 y = 0; 241 y = 0;
242 } 242 }
243 243
244 if (ASIC_IS_AVIVO(rdev)) { 244 /* fixed on DCE6 and newer */
245 if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE6(rdev)) {
245 int i = 0; 246 int i = 0;
246 struct drm_crtc *crtc_p; 247 struct drm_crtc *crtc_p;
247 248
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index edfc54e41842..0d6562bb0c93 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -429,7 +429,8 @@ bool radeon_card_posted(struct radeon_device *rdev)
429{ 429{
430 uint32_t reg; 430 uint32_t reg;
431 431
432 if (efi_enabled && rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) 432 if (efi_enabled(EFI_BOOT) &&
433 rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE)
433 return false; 434 return false;
434 435
435 /* first check CRTCs */ 436 /* first check CRTCs */
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 1da2386d7cf7..ff3def784619 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1122,7 +1122,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
1122 if (ret) { 1122 if (ret) {
1123 kfree(radeon_fb); 1123 kfree(radeon_fb);
1124 drm_gem_object_unreference_unlocked(obj); 1124 drm_gem_object_unreference_unlocked(obj);
1125 return NULL; 1125 return ERR_PTR(ret);
1126 } 1126 }
1127 1127
1128 return &radeon_fb->base; 1128 return &radeon_fb->base;
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 4dfa605e2d14..34e25471aeaa 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -306,6 +306,9 @@
306#define USB_VENDOR_ID_EZKEY 0x0518 306#define USB_VENDOR_ID_EZKEY 0x0518
307#define USB_DEVICE_ID_BTC_8193 0x0002 307#define USB_DEVICE_ID_BTC_8193 0x0002
308 308
309#define USB_VENDOR_ID_FORMOSA 0x147a
310#define USB_DEVICE_ID_FORMOSA_IR_RECEIVER 0xe03e
311
309#define USB_VENDOR_ID_FREESCALE 0x15A2 312#define USB_VENDOR_ID_FREESCALE 0x15A2
310#define USB_DEVICE_ID_FREESCALE_MX28 0x004F 313#define USB_DEVICE_ID_FREESCALE_MX28 0x004F
311 314
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 12e4fdc810bf..e766b5614ef5 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -540,13 +540,24 @@ static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf,
540{ 540{
541 struct i2c_client *client = hid->driver_data; 541 struct i2c_client *client = hid->driver_data;
542 int report_id = buf[0]; 542 int report_id = buf[0];
543 int ret;
543 544
544 if (report_type == HID_INPUT_REPORT) 545 if (report_type == HID_INPUT_REPORT)
545 return -EINVAL; 546 return -EINVAL;
546 547
547 return i2c_hid_set_report(client, 548 if (report_id) {
549 buf++;
550 count--;
551 }
552
553 ret = i2c_hid_set_report(client,
548 report_type == HID_FEATURE_REPORT ? 0x03 : 0x02, 554 report_type == HID_FEATURE_REPORT ? 0x03 : 0x02,
549 report_id, buf, count); 555 report_id, buf, count);
556
557 if (report_id && ret >= 0)
558 ret++; /* add report_id to the number of transfered bytes */
559
560 return ret;
550} 561}
551 562
552static int i2c_hid_parse(struct hid_device *hid) 563static int i2c_hid_parse(struct hid_device *hid)
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index ac9e35228254..e0e6abf1cd3b 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -70,6 +70,7 @@ static const struct hid_blacklist {
70 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, 70 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
71 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 71 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
72 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 72 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
73 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
73 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, 74 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
74 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, 75 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET },
75 { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, 76 { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS },
diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c
index 369a39de4ff3..f9179b2585a9 100644
--- a/drivers/input/misc/max8925_onkey.c
+++ b/drivers/input/misc/max8925_onkey.c
@@ -100,9 +100,6 @@ static int max8925_onkey_probe(struct platform_device *pdev)
100 input->dev.parent = &pdev->dev; 100 input->dev.parent = &pdev->dev;
101 input_set_capability(input, EV_KEY, KEY_POWER); 101 input_set_capability(input, EV_KEY, KEY_POWER);
102 102
103 irq[0] += chip->irq_base;
104 irq[1] += chip->irq_base;
105
106 error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler, 103 error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler,
107 IRQF_ONESHOT, "onkey-down", info); 104 IRQF_ONESHOT, "onkey-down", info);
108 if (error < 0) { 105 if (error < 0) {
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 81837b0710a9..faf10ba1ed9a 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -975,6 +975,38 @@ static void __init free_iommu_all(void)
975} 975}
976 976
977/* 977/*
978 * Family15h Model 10h-1fh erratum 746 (IOMMU Logging May Stall Translations)
979 * Workaround:
980 * BIOS should disable L2B micellaneous clock gating by setting
981 * L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0F2xF4_x90[2]) = 1b
982 */
983static void __init amd_iommu_erratum_746_workaround(struct amd_iommu *iommu)
984{
985 u32 value;
986
987 if ((boot_cpu_data.x86 != 0x15) ||
988 (boot_cpu_data.x86_model < 0x10) ||
989 (boot_cpu_data.x86_model > 0x1f))
990 return;
991
992 pci_write_config_dword(iommu->dev, 0xf0, 0x90);
993 pci_read_config_dword(iommu->dev, 0xf4, &value);
994
995 if (value & BIT(2))
996 return;
997
998 /* Select NB indirect register 0x90 and enable writing */
999 pci_write_config_dword(iommu->dev, 0xf0, 0x90 | (1 << 8));
1000
1001 pci_write_config_dword(iommu->dev, 0xf4, value | 0x4);
1002 pr_info("AMD-Vi: Applying erratum 746 workaround for IOMMU at %s\n",
1003 dev_name(&iommu->dev->dev));
1004
1005 /* Clear the enable writing bit */
1006 pci_write_config_dword(iommu->dev, 0xf0, 0x90);
1007}
1008
1009/*
978 * This function clues the initialization function for one IOMMU 1010 * This function clues the initialization function for one IOMMU
979 * together and also allocates the command buffer and programs the 1011 * together and also allocates the command buffer and programs the
980 * hardware. It does NOT enable the IOMMU. This is done afterwards. 1012 * hardware. It does NOT enable the IOMMU. This is done afterwards.
@@ -1172,6 +1204,8 @@ static int iommu_init_pci(struct amd_iommu *iommu)
1172 iommu->stored_l2[i] = iommu_read_l2(iommu, i); 1204 iommu->stored_l2[i] = iommu_read_l2(iommu, i);
1173 } 1205 }
1174 1206
1207 amd_iommu_erratum_746_workaround(iommu);
1208
1175 return pci_enable_device(iommu->dev); 1209 return pci_enable_device(iommu->dev);
1176} 1210}
1177 1211
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index b9d091157884..eca28014ef3e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4234,6 +4234,21 @@ static struct iommu_ops intel_iommu_ops = {
4234 .pgsize_bitmap = INTEL_IOMMU_PGSIZES, 4234 .pgsize_bitmap = INTEL_IOMMU_PGSIZES,
4235}; 4235};
4236 4236
4237static void quirk_iommu_g4x_gfx(struct pci_dev *dev)
4238{
4239 /* G4x/GM45 integrated gfx dmar support is totally busted. */
4240 printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
4241 dmar_map_gfx = 0;
4242}
4243
4244DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_g4x_gfx);
4245DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_g4x_gfx);
4246DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e10, quirk_iommu_g4x_gfx);
4247DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e20, quirk_iommu_g4x_gfx);
4248DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e30, quirk_iommu_g4x_gfx);
4249DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e40, quirk_iommu_g4x_gfx);
4250DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e90, quirk_iommu_g4x_gfx);
4251
4237static void quirk_iommu_rwbf(struct pci_dev *dev) 4252static void quirk_iommu_rwbf(struct pci_dev *dev)
4238{ 4253{
4239 /* 4254 /*
@@ -4242,12 +4257,6 @@ static void quirk_iommu_rwbf(struct pci_dev *dev)
4242 */ 4257 */
4243 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n"); 4258 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n");
4244 rwbf_quirk = 1; 4259 rwbf_quirk = 1;
4245
4246 /* https://bugzilla.redhat.com/show_bug.cgi?id=538163 */
4247 if (dev->revision == 0x07) {
4248 printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
4249 dmar_map_gfx = 0;
4250 }
4251} 4260}
4252 4261
4253DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf); 4262DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf);
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 68452b768da2..03a0a01a4054 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -248,6 +248,8 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
248 CAPIMSG_APPID(data), CAPIMSG_MSGID(data), l, 248 CAPIMSG_APPID(data), CAPIMSG_MSGID(data), l,
249 CAPIMSG_CONTROL(data)); 249 CAPIMSG_CONTROL(data));
250 l -= 12; 250 l -= 12;
251 if (l <= 0)
252 return;
251 dbgline = kmalloc(3 * l, GFP_ATOMIC); 253 dbgline = kmalloc(3 * l, GFP_ATOMIC);
252 if (!dbgline) 254 if (!dbgline)
253 return; 255 return;
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 3d8984edeff7..9e58dbd8d8cb 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -340,24 +340,22 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
340} 340}
341 341
342/* 342/*
343 * validate_rebuild_devices 343 * validate_raid_redundancy
344 * @rs 344 * @rs
345 * 345 *
346 * Determine if the devices specified for rebuild can result in a valid 346 * Determine if there are enough devices in the array that haven't
347 * usable array that is capable of rebuilding the given devices. 347 * failed (or are being rebuilt) to form a usable array.
348 * 348 *
349 * Returns: 0 on success, -EINVAL on failure. 349 * Returns: 0 on success, -EINVAL on failure.
350 */ 350 */
351static int validate_rebuild_devices(struct raid_set *rs) 351static int validate_raid_redundancy(struct raid_set *rs)
352{ 352{
353 unsigned i, rebuild_cnt = 0; 353 unsigned i, rebuild_cnt = 0;
354 unsigned rebuilds_per_group, copies, d; 354 unsigned rebuilds_per_group, copies, d;
355 355
356 if (!(rs->print_flags & DMPF_REBUILD))
357 return 0;
358
359 for (i = 0; i < rs->md.raid_disks; i++) 356 for (i = 0; i < rs->md.raid_disks; i++)
360 if (!test_bit(In_sync, &rs->dev[i].rdev.flags)) 357 if (!test_bit(In_sync, &rs->dev[i].rdev.flags) ||
358 !rs->dev[i].rdev.sb_page)
361 rebuild_cnt++; 359 rebuild_cnt++;
362 360
363 switch (rs->raid_type->level) { 361 switch (rs->raid_type->level) {
@@ -393,27 +391,24 @@ static int validate_rebuild_devices(struct raid_set *rs)
393 * A A B B C 391 * A A B B C
394 * C D D E E 392 * C D D E E
395 */ 393 */
396 rebuilds_per_group = 0;
397 for (i = 0; i < rs->md.raid_disks * copies; i++) { 394 for (i = 0; i < rs->md.raid_disks * copies; i++) {
395 if (!(i % copies))
396 rebuilds_per_group = 0;
398 d = i % rs->md.raid_disks; 397 d = i % rs->md.raid_disks;
399 if (!test_bit(In_sync, &rs->dev[d].rdev.flags) && 398 if ((!rs->dev[d].rdev.sb_page ||
399 !test_bit(In_sync, &rs->dev[d].rdev.flags)) &&
400 (++rebuilds_per_group >= copies)) 400 (++rebuilds_per_group >= copies))
401 goto too_many; 401 goto too_many;
402 if (!((i + 1) % copies))
403 rebuilds_per_group = 0;
404 } 402 }
405 break; 403 break;
406 default: 404 default:
407 DMERR("The rebuild parameter is not supported for %s", 405 if (rebuild_cnt)
408 rs->raid_type->name); 406 return -EINVAL;
409 rs->ti->error = "Rebuild not supported for this RAID type";
410 return -EINVAL;
411 } 407 }
412 408
413 return 0; 409 return 0;
414 410
415too_many: 411too_many:
416 rs->ti->error = "Too many rebuild devices specified";
417 return -EINVAL; 412 return -EINVAL;
418} 413}
419 414
@@ -664,9 +659,6 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
664 } 659 }
665 rs->md.dev_sectors = sectors_per_dev; 660 rs->md.dev_sectors = sectors_per_dev;
666 661
667 if (validate_rebuild_devices(rs))
668 return -EINVAL;
669
670 /* Assume there are no metadata devices until the drives are parsed */ 662 /* Assume there are no metadata devices until the drives are parsed */
671 rs->md.persistent = 0; 663 rs->md.persistent = 0;
672 rs->md.external = 1; 664 rs->md.external = 1;
@@ -995,28 +987,10 @@ static int super_validate(struct mddev *mddev, struct md_rdev *rdev)
995static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs) 987static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
996{ 988{
997 int ret; 989 int ret;
998 unsigned redundancy = 0;
999 struct raid_dev *dev; 990 struct raid_dev *dev;
1000 struct md_rdev *rdev, *tmp, *freshest; 991 struct md_rdev *rdev, *tmp, *freshest;
1001 struct mddev *mddev = &rs->md; 992 struct mddev *mddev = &rs->md;
1002 993
1003 switch (rs->raid_type->level) {
1004 case 1:
1005 redundancy = rs->md.raid_disks - 1;
1006 break;
1007 case 4:
1008 case 5:
1009 case 6:
1010 redundancy = rs->raid_type->parity_devs;
1011 break;
1012 case 10:
1013 redundancy = raid10_md_layout_to_copies(mddev->layout) - 1;
1014 break;
1015 default:
1016 ti->error = "Unknown RAID type";
1017 return -EINVAL;
1018 }
1019
1020 freshest = NULL; 994 freshest = NULL;
1021 rdev_for_each_safe(rdev, tmp, mddev) { 995 rdev_for_each_safe(rdev, tmp, mddev) {
1022 /* 996 /*
@@ -1045,44 +1019,43 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
1045 break; 1019 break;
1046 default: 1020 default:
1047 dev = container_of(rdev, struct raid_dev, rdev); 1021 dev = container_of(rdev, struct raid_dev, rdev);
1048 if (redundancy--) { 1022 if (dev->meta_dev)
1049 if (dev->meta_dev) 1023 dm_put_device(ti, dev->meta_dev);
1050 dm_put_device(ti, dev->meta_dev);
1051
1052 dev->meta_dev = NULL;
1053 rdev->meta_bdev = NULL;
1054 1024
1055 if (rdev->sb_page) 1025 dev->meta_dev = NULL;
1056 put_page(rdev->sb_page); 1026 rdev->meta_bdev = NULL;
1057 1027
1058 rdev->sb_page = NULL; 1028 if (rdev->sb_page)
1029 put_page(rdev->sb_page);
1059 1030
1060 rdev->sb_loaded = 0; 1031 rdev->sb_page = NULL;
1061 1032
1062 /* 1033 rdev->sb_loaded = 0;
1063 * We might be able to salvage the data device
1064 * even though the meta device has failed. For
1065 * now, we behave as though '- -' had been
1066 * set for this device in the table.
1067 */
1068 if (dev->data_dev)
1069 dm_put_device(ti, dev->data_dev);
1070 1034
1071 dev->data_dev = NULL; 1035 /*
1072 rdev->bdev = NULL; 1036 * We might be able to salvage the data device
1037 * even though the meta device has failed. For
1038 * now, we behave as though '- -' had been
1039 * set for this device in the table.
1040 */
1041 if (dev->data_dev)
1042 dm_put_device(ti, dev->data_dev);
1073 1043
1074 list_del(&rdev->same_set); 1044 dev->data_dev = NULL;
1045 rdev->bdev = NULL;
1075 1046
1076 continue; 1047 list_del(&rdev->same_set);
1077 }
1078 ti->error = "Failed to load superblock";
1079 return ret;
1080 } 1048 }
1081 } 1049 }
1082 1050
1083 if (!freshest) 1051 if (!freshest)
1084 return 0; 1052 return 0;
1085 1053
1054 if (validate_raid_redundancy(rs)) {
1055 rs->ti->error = "Insufficient redundancy to activate array";
1056 return -EINVAL;
1057 }
1058
1086 /* 1059 /*
1087 * Validation of the freshest device provides the source of 1060 * Validation of the freshest device provides the source of
1088 * validation for the remaining devices. 1061 * validation for the remaining devices.
@@ -1432,7 +1405,7 @@ static void raid_resume(struct dm_target *ti)
1432 1405
1433static struct target_type raid_target = { 1406static struct target_type raid_target = {
1434 .name = "raid", 1407 .name = "raid",
1435 .version = {1, 4, 0}, 1408 .version = {1, 4, 1},
1436 .module = THIS_MODULE, 1409 .module = THIS_MODULE,
1437 .ctr = raid_ctr, 1410 .ctr = raid_ctr,
1438 .dtr = raid_dtr, 1411 .dtr = raid_dtr,
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 675ae5274016..5409607d4875 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2746,19 +2746,9 @@ static int thin_iterate_devices(struct dm_target *ti,
2746 return 0; 2746 return 0;
2747} 2747}
2748 2748
2749/*
2750 * A thin device always inherits its queue limits from its pool.
2751 */
2752static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)
2753{
2754 struct thin_c *tc = ti->private;
2755
2756 *limits = bdev_get_queue(tc->pool_dev->bdev)->limits;
2757}
2758
2759static struct target_type thin_target = { 2749static struct target_type thin_target = {
2760 .name = "thin", 2750 .name = "thin",
2761 .version = {1, 6, 0}, 2751 .version = {1, 7, 0},
2762 .module = THIS_MODULE, 2752 .module = THIS_MODULE,
2763 .ctr = thin_ctr, 2753 .ctr = thin_ctr,
2764 .dtr = thin_dtr, 2754 .dtr = thin_dtr,
@@ -2767,7 +2757,6 @@ static struct target_type thin_target = {
2767 .postsuspend = thin_postsuspend, 2757 .postsuspend = thin_postsuspend,
2768 .status = thin_status, 2758 .status = thin_status,
2769 .iterate_devices = thin_iterate_devices, 2759 .iterate_devices = thin_iterate_devices,
2770 .io_hints = thin_io_hints,
2771}; 2760};
2772 2761
2773/*----------------------------------------------------------------*/ 2762/*----------------------------------------------------------------*/
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index c72e4d5a9617..314a0e2faf79 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1188,6 +1188,7 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
1188{ 1188{
1189 struct dm_target *ti; 1189 struct dm_target *ti;
1190 sector_t len; 1190 sector_t len;
1191 unsigned num_requests;
1191 1192
1192 do { 1193 do {
1193 ti = dm_table_find_target(ci->map, ci->sector); 1194 ti = dm_table_find_target(ci->map, ci->sector);
@@ -1200,7 +1201,8 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
1200 * reconfiguration might also have changed that since the 1201 * reconfiguration might also have changed that since the
1201 * check was performed. 1202 * check was performed.
1202 */ 1203 */
1203 if (!get_num_requests || !get_num_requests(ti)) 1204 num_requests = get_num_requests ? get_num_requests(ti) : 0;
1205 if (!num_requests)
1204 return -EOPNOTSUPP; 1206 return -EOPNOTSUPP;
1205 1207
1206 if (is_split_required && !is_split_required(ti)) 1208 if (is_split_required && !is_split_required(ti))
@@ -1208,7 +1210,7 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
1208 else 1210 else
1209 len = min(ci->sector_count, max_io_len(ci->sector, ti)); 1211 len = min(ci->sector_count, max_io_len(ci->sector, ti));
1210 1212
1211 __issue_target_requests(ci, ti, ti->num_discard_requests, len); 1213 __issue_target_requests(ci, ti, num_requests, len);
1212 1214
1213 ci->sector += len; 1215 ci->sector += len;
1214 } while (ci->sector_count -= len); 1216 } while (ci->sector_count -= len);
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
index 391e23e6a647..582bda543520 100644
--- a/drivers/mfd/88pm800.c
+++ b/drivers/mfd/88pm800.c
@@ -531,7 +531,7 @@ static int pm800_probe(struct i2c_client *client,
531 ret = device_800_init(chip, pdata); 531 ret = device_800_init(chip, pdata);
532 if (ret) { 532 if (ret) {
533 dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id); 533 dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id);
534 goto err_800_init; 534 goto err_subchip_alloc;
535 } 535 }
536 536
537 ret = pm800_pages_init(chip); 537 ret = pm800_pages_init(chip);
@@ -546,10 +546,8 @@ static int pm800_probe(struct i2c_client *client,
546err_page_init: 546err_page_init:
547 mfd_remove_devices(chip->dev); 547 mfd_remove_devices(chip->dev);
548 device_irq_exit_800(chip); 548 device_irq_exit_800(chip);
549err_800_init:
550 devm_kfree(&client->dev, subchip);
551err_subchip_alloc: 549err_subchip_alloc:
552 pm80x_deinit(client); 550 pm80x_deinit();
553out_init: 551out_init:
554 return ret; 552 return ret;
555} 553}
@@ -562,9 +560,7 @@ static int pm800_remove(struct i2c_client *client)
562 device_irq_exit_800(chip); 560 device_irq_exit_800(chip);
563 561
564 pm800_pages_exit(chip); 562 pm800_pages_exit(chip);
565 devm_kfree(&client->dev, chip->subchip); 563 pm80x_deinit();
566
567 pm80x_deinit(client);
568 564
569 return 0; 565 return 0;
570} 566}
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c
index e671230be2b1..65d7ac099b20 100644
--- a/drivers/mfd/88pm805.c
+++ b/drivers/mfd/88pm805.c
@@ -257,7 +257,7 @@ static int pm805_probe(struct i2c_client *client,
257 pdata->plat_config(chip, pdata); 257 pdata->plat_config(chip, pdata);
258 258
259err_805_init: 259err_805_init:
260 pm80x_deinit(client); 260 pm80x_deinit();
261out_init: 261out_init:
262 return ret; 262 return ret;
263} 263}
@@ -269,7 +269,7 @@ static int pm805_remove(struct i2c_client *client)
269 mfd_remove_devices(chip->dev); 269 mfd_remove_devices(chip->dev);
270 device_irq_exit_805(chip); 270 device_irq_exit_805(chip);
271 271
272 pm80x_deinit(client); 272 pm80x_deinit();
273 273
274 return 0; 274 return 0;
275} 275}
diff --git a/drivers/mfd/88pm80x.c b/drivers/mfd/88pm80x.c
index 1adb355d86d1..f736a46eb8c0 100644
--- a/drivers/mfd/88pm80x.c
+++ b/drivers/mfd/88pm80x.c
@@ -48,14 +48,12 @@ int pm80x_init(struct i2c_client *client,
48 ret = PTR_ERR(map); 48 ret = PTR_ERR(map);
49 dev_err(&client->dev, "Failed to allocate register map: %d\n", 49 dev_err(&client->dev, "Failed to allocate register map: %d\n",
50 ret); 50 ret);
51 goto err_regmap_init; 51 return ret;
52 } 52 }
53 53
54 chip->id = id->driver_data; 54 chip->id = id->driver_data;
55 if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) { 55 if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805)
56 ret = -EINVAL; 56 return -EINVAL;
57 goto err_chip_id;
58 }
59 57
60 chip->client = client; 58 chip->client = client;
61 chip->regmap = map; 59 chip->regmap = map;
@@ -82,19 +80,11 @@ int pm80x_init(struct i2c_client *client,
82 } 80 }
83 81
84 return 0; 82 return 0;
85
86err_chip_id:
87 regmap_exit(map);
88err_regmap_init:
89 devm_kfree(&client->dev, chip);
90 return ret;
91} 83}
92EXPORT_SYMBOL_GPL(pm80x_init); 84EXPORT_SYMBOL_GPL(pm80x_init);
93 85
94int pm80x_deinit(struct i2c_client *client) 86int pm80x_deinit(void)
95{ 87{
96 struct pm80x_chip *chip = i2c_get_clientdata(client);
97
98 /* 88 /*
99 * workaround: clear the dependency between pm800 and pm805. 89 * workaround: clear the dependency between pm800 and pm805.
100 * would remove it after HW chip fixes the issue. 90 * would remove it after HW chip fixes the issue.
@@ -103,10 +93,6 @@ int pm80x_deinit(struct i2c_client *client)
103 g_pm80x_chip->companion = NULL; 93 g_pm80x_chip->companion = NULL;
104 else 94 else
105 g_pm80x_chip = NULL; 95 g_pm80x_chip = NULL;
106
107 regmap_exit(chip->regmap);
108 devm_kfree(&client->dev, chip);
109
110 return 0; 96 return 0;
111} 97}
112EXPORT_SYMBOL_GPL(pm80x_deinit); 98EXPORT_SYMBOL_GPL(pm80x_deinit);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 47ad4e270877..ff553babf455 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -237,6 +237,7 @@ config MFD_TPS65910
237 depends on I2C=y && GPIOLIB 237 depends on I2C=y && GPIOLIB
238 select MFD_CORE 238 select MFD_CORE
239 select REGMAP_I2C 239 select REGMAP_I2C
240 select REGMAP_IRQ
240 select IRQ_DOMAIN 241 select IRQ_DOMAIN
241 help 242 help
242 if you say yes here you get support for the TPS65910 series of 243 if you say yes here you get support for the TPS65910 series of
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8b977f8045ae..b90409c23664 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -9,7 +9,7 @@ obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o
9obj-$(CONFIG_MFD_SM501) += sm501.o 9obj-$(CONFIG_MFD_SM501) += sm501.o
10obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o 10obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o
11 11
12rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o 12rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o
13obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o 13obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o
14 14
15obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o 15obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 05a7af4b9768..104514228b74 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -19,6 +19,7 @@
19#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
20#include <linux/mfd/abx500.h> 20#include <linux/mfd/abx500.h>
21#include <linux/mfd/abx500/ab8500.h> 21#include <linux/mfd/abx500/ab8500.h>
22#include <linux/mfd/abx500/ab8500-bm.h>
22#include <linux/mfd/dbx500-prcmu.h> 23#include <linux/mfd/dbx500-prcmu.h>
23#include <linux/regulator/ab8500.h> 24#include <linux/regulator/ab8500.h>
24#include <linux/of.h> 25#include <linux/of.h>
@@ -924,7 +925,7 @@ static struct resource ab8505_iddet_resources[] = {
924 925
925static struct resource ab8500_temp_resources[] = { 926static struct resource ab8500_temp_resources[] = {
926 { 927 {
927 .name = "AB8500_TEMP_WARM", 928 .name = "ABX500_TEMP_WARM",
928 .start = AB8500_INT_TEMP_WARM, 929 .start = AB8500_INT_TEMP_WARM,
929 .end = AB8500_INT_TEMP_WARM, 930 .end = AB8500_INT_TEMP_WARM,
930 .flags = IORESOURCE_IRQ, 931 .flags = IORESOURCE_IRQ,
@@ -1000,8 +1001,8 @@ static struct mfd_cell abx500_common_devs[] = {
1000 .of_compatible = "stericsson,ab8500-denc", 1001 .of_compatible = "stericsson,ab8500-denc",
1001 }, 1002 },
1002 { 1003 {
1003 .name = "ab8500-temp", 1004 .name = "abx500-temp",
1004 .of_compatible = "stericsson,ab8500-temp", 1005 .of_compatible = "stericsson,abx500-temp",
1005 .num_resources = ARRAY_SIZE(ab8500_temp_resources), 1006 .num_resources = ARRAY_SIZE(ab8500_temp_resources),
1006 .resources = ab8500_temp_resources, 1007 .resources = ab8500_temp_resources,
1007 }, 1008 },
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index bc8a3edb6bbf..b562c7bf8a46 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -115,7 +115,7 @@ static irqreturn_t arizona_underclocked(int irq, void *data)
115 if (val & ARIZONA_ADC_UNDERCLOCKED_STS) 115 if (val & ARIZONA_ADC_UNDERCLOCKED_STS)
116 dev_err(arizona->dev, "ADC underclocked\n"); 116 dev_err(arizona->dev, "ADC underclocked\n");
117 if (val & ARIZONA_MIXER_UNDERCLOCKED_STS) 117 if (val & ARIZONA_MIXER_UNDERCLOCKED_STS)
118 dev_err(arizona->dev, "Mixer underclocked\n"); 118 dev_err(arizona->dev, "Mixer dropped sample\n");
119 119
120 return IRQ_HANDLED; 120 return IRQ_HANDLED;
121} 121}
@@ -239,7 +239,12 @@ static int arizona_runtime_resume(struct device *dev)
239 return ret; 239 return ret;
240 } 240 }
241 241
242 regcache_sync(arizona->regmap); 242 ret = regcache_sync(arizona->regmap);
243 if (ret != 0) {
244 dev_err(arizona->dev, "Failed to restore register cache\n");
245 regulator_disable(arizona->dcvdd);
246 return ret;
247 }
243 248
244 return 0; 249 return 0;
245} 250}
@@ -258,10 +263,36 @@ static int arizona_runtime_suspend(struct device *dev)
258} 263}
259#endif 264#endif
260 265
266#ifdef CONFIG_PM_SLEEP
267static int arizona_resume_noirq(struct device *dev)
268{
269 struct arizona *arizona = dev_get_drvdata(dev);
270
271 dev_dbg(arizona->dev, "Early resume, disabling IRQ\n");
272 disable_irq(arizona->irq);
273
274 return 0;
275}
276
277static int arizona_resume(struct device *dev)
278{
279 struct arizona *arizona = dev_get_drvdata(dev);
280
281 dev_dbg(arizona->dev, "Late resume, reenabling IRQ\n");
282 enable_irq(arizona->irq);
283
284 return 0;
285}
286#endif
287
261const struct dev_pm_ops arizona_pm_ops = { 288const struct dev_pm_ops arizona_pm_ops = {
262 SET_RUNTIME_PM_OPS(arizona_runtime_suspend, 289 SET_RUNTIME_PM_OPS(arizona_runtime_suspend,
263 arizona_runtime_resume, 290 arizona_runtime_resume,
264 NULL) 291 NULL)
292 SET_SYSTEM_SLEEP_PM_OPS(NULL, arizona_resume)
293#ifdef CONFIG_PM_SLEEP
294 .resume_noirq = arizona_resume_noirq,
295#endif
265}; 296};
266EXPORT_SYMBOL_GPL(arizona_pm_ops); 297EXPORT_SYMBOL_GPL(arizona_pm_ops);
267 298
@@ -270,19 +301,19 @@ static struct mfd_cell early_devs[] = {
270}; 301};
271 302
272static struct mfd_cell wm5102_devs[] = { 303static struct mfd_cell wm5102_devs[] = {
304 { .name = "arizona-micsupp" },
273 { .name = "arizona-extcon" }, 305 { .name = "arizona-extcon" },
274 { .name = "arizona-gpio" }, 306 { .name = "arizona-gpio" },
275 { .name = "arizona-haptics" }, 307 { .name = "arizona-haptics" },
276 { .name = "arizona-micsupp" },
277 { .name = "arizona-pwm" }, 308 { .name = "arizona-pwm" },
278 { .name = "wm5102-codec" }, 309 { .name = "wm5102-codec" },
279}; 310};
280 311
281static struct mfd_cell wm5110_devs[] = { 312static struct mfd_cell wm5110_devs[] = {
313 { .name = "arizona-micsupp" },
282 { .name = "arizona-extcon" }, 314 { .name = "arizona-extcon" },
283 { .name = "arizona-gpio" }, 315 { .name = "arizona-gpio" },
284 { .name = "arizona-haptics" }, 316 { .name = "arizona-haptics" },
285 { .name = "arizona-micsupp" },
286 { .name = "arizona-pwm" }, 317 { .name = "arizona-pwm" },
287 { .name = "wm5110-codec" }, 318 { .name = "wm5110-codec" },
288}; 319};
@@ -479,6 +510,29 @@ int arizona_dev_init(struct arizona *arizona)
479 goto err_reset; 510 goto err_reset;
480 } 511 }
481 512
513 for (i = 0; i < ARIZONA_MAX_MICBIAS; i++) {
514 if (!arizona->pdata.micbias[i].mV)
515 continue;
516
517 val = (arizona->pdata.micbias[i].mV - 1500) / 100;
518 val <<= ARIZONA_MICB1_LVL_SHIFT;
519
520 if (arizona->pdata.micbias[i].ext_cap)
521 val |= ARIZONA_MICB1_EXT_CAP;
522
523 if (arizona->pdata.micbias[i].discharge)
524 val |= ARIZONA_MICB1_DISCH;
525
526 if (arizona->pdata.micbias[i].fast_start)
527 val |= ARIZONA_MICB1_RATE;
528
529 regmap_update_bits(arizona->regmap,
530 ARIZONA_MIC_BIAS_CTRL_1 + i,
531 ARIZONA_MICB1_LVL_MASK |
532 ARIZONA_MICB1_DISCH |
533 ARIZONA_MICB1_RATE, val);
534 }
535
482 for (i = 0; i < ARIZONA_MAX_INPUT; i++) { 536 for (i = 0; i < ARIZONA_MAX_INPUT; i++) {
483 /* Default for both is 0 so noop with defaults */ 537 /* Default for both is 0 so noop with defaults */
484 val = arizona->pdata.dmic_ref[i] 538 val = arizona->pdata.dmic_ref[i]
diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c
index 74713bf5371f..2bec5f0db3ee 100644
--- a/drivers/mfd/arizona-irq.c
+++ b/drivers/mfd/arizona-irq.c
@@ -176,14 +176,7 @@ int arizona_irq_init(struct arizona *arizona)
176 aod = &wm5102_aod; 176 aod = &wm5102_aod;
177 irq = &wm5102_irq; 177 irq = &wm5102_irq;
178 178
179 switch (arizona->rev) { 179 ctrlif_error = false;
180 case 0:
181 case 1:
182 ctrlif_error = false;
183 break;
184 default:
185 break;
186 }
187 break; 180 break;
188#endif 181#endif
189#ifdef CONFIG_MFD_WM5110 182#ifdef CONFIG_MFD_WM5110
@@ -191,14 +184,7 @@ int arizona_irq_init(struct arizona *arizona)
191 aod = &wm5110_aod; 184 aod = &wm5110_aod;
192 irq = &wm5110_irq; 185 irq = &wm5110_irq;
193 186
194 switch (arizona->rev) { 187 ctrlif_error = false;
195 case 0:
196 case 1:
197 ctrlif_error = false;
198 break;
199 default:
200 break;
201 }
202 break; 188 break;
203#endif 189#endif
204 default: 190 default:
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
index ac74a4d1daea..885e56780358 100644
--- a/drivers/mfd/da9052-i2c.c
+++ b/drivers/mfd/da9052-i2c.c
@@ -27,6 +27,66 @@
27#include <linux/of_device.h> 27#include <linux/of_device.h>
28#endif 28#endif
29 29
30/* I2C safe register check */
31static inline bool i2c_safe_reg(unsigned char reg)
32{
33 switch (reg) {
34 case DA9052_STATUS_A_REG:
35 case DA9052_STATUS_B_REG:
36 case DA9052_STATUS_C_REG:
37 case DA9052_STATUS_D_REG:
38 case DA9052_ADC_RES_L_REG:
39 case DA9052_ADC_RES_H_REG:
40 case DA9052_VDD_RES_REG:
41 case DA9052_ICHG_AV_REG:
42 case DA9052_TBAT_RES_REG:
43 case DA9052_ADCIN4_RES_REG:
44 case DA9052_ADCIN5_RES_REG:
45 case DA9052_ADCIN6_RES_REG:
46 case DA9052_TJUNC_RES_REG:
47 case DA9052_TSI_X_MSB_REG:
48 case DA9052_TSI_Y_MSB_REG:
49 case DA9052_TSI_LSB_REG:
50 case DA9052_TSI_Z_MSB_REG:
51 return true;
52 default:
53 return false;
54 }
55}
56
57/*
58 * There is an issue with DA9052 and DA9053_AA/BA/BB PMIC where the PMIC
59 * gets lockup up or fails to respond following a system reset.
60 * This fix is to follow any read or write with a dummy read to a safe
61 * register.
62 */
63int da9052_i2c_fix(struct da9052 *da9052, unsigned char reg)
64{
65 int val;
66
67 switch (da9052->chip_id) {
68 case DA9052:
69 case DA9053_AA:
70 case DA9053_BA:
71 case DA9053_BB:
72 /* A dummy read to a safe register address. */
73 if (!i2c_safe_reg(reg))
74 return regmap_read(da9052->regmap,
75 DA9052_PARK_REGISTER,
76 &val);
77 break;
78 default:
79 /*
80 * For other chips parking of I2C register
81 * to a safe place is not required.
82 */
83 break;
84 }
85
86 return 0;
87}
88EXPORT_SYMBOL(da9052_i2c_fix);
89
30static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) 90static int da9052_i2c_enable_multiwrite(struct da9052 *da9052)
31{ 91{
32 int reg_val, ret; 92 int reg_val, ret;
@@ -83,6 +143,7 @@ static int da9052_i2c_probe(struct i2c_client *client,
83 143
84 da9052->dev = &client->dev; 144 da9052->dev = &client->dev;
85 da9052->chip_irq = client->irq; 145 da9052->chip_irq = client->irq;
146 da9052->fix_io = da9052_i2c_fix;
86 147
87 i2c_set_clientdata(client, da9052); 148 i2c_set_clientdata(client, da9052);
88 149
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index dc8826d8d69d..e42a417adc5f 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -32,6 +32,7 @@
32#include <linux/regulator/db8500-prcmu.h> 32#include <linux/regulator/db8500-prcmu.h>
33#include <linux/regulator/machine.h> 33#include <linux/regulator/machine.h>
34#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
35#include <linux/platform_data/ux500_wdt.h>
35#include <asm/hardware/gic.h> 36#include <asm/hardware/gic.h>
36#include <mach/hardware.h> 37#include <mach/hardware.h>
37#include <mach/irqs.h> 38#include <mach/irqs.h>
@@ -2212,21 +2213,25 @@ int db8500_prcmu_config_a9wdog(u8 num, bool sleep_auto_off)
2212 sleep_auto_off ? A9WDOG_AUTO_OFF_EN : 2213 sleep_auto_off ? A9WDOG_AUTO_OFF_EN :
2213 A9WDOG_AUTO_OFF_DIS); 2214 A9WDOG_AUTO_OFF_DIS);
2214} 2215}
2216EXPORT_SYMBOL(db8500_prcmu_config_a9wdog);
2215 2217
2216int db8500_prcmu_enable_a9wdog(u8 id) 2218int db8500_prcmu_enable_a9wdog(u8 id)
2217{ 2219{
2218 return prcmu_a9wdog(MB4H_A9WDOG_EN, id, 0, 0, 0); 2220 return prcmu_a9wdog(MB4H_A9WDOG_EN, id, 0, 0, 0);
2219} 2221}
2222EXPORT_SYMBOL(db8500_prcmu_enable_a9wdog);
2220 2223
2221int db8500_prcmu_disable_a9wdog(u8 id) 2224int db8500_prcmu_disable_a9wdog(u8 id)
2222{ 2225{
2223 return prcmu_a9wdog(MB4H_A9WDOG_DIS, id, 0, 0, 0); 2226 return prcmu_a9wdog(MB4H_A9WDOG_DIS, id, 0, 0, 0);
2224} 2227}
2228EXPORT_SYMBOL(db8500_prcmu_disable_a9wdog);
2225 2229
2226int db8500_prcmu_kick_a9wdog(u8 id) 2230int db8500_prcmu_kick_a9wdog(u8 id)
2227{ 2231{
2228 return prcmu_a9wdog(MB4H_A9WDOG_KICK, id, 0, 0, 0); 2232 return prcmu_a9wdog(MB4H_A9WDOG_KICK, id, 0, 0, 0);
2229} 2233}
2234EXPORT_SYMBOL(db8500_prcmu_kick_a9wdog);
2230 2235
2231/* 2236/*
2232 * timeout is 28 bit, in ms. 2237 * timeout is 28 bit, in ms.
@@ -2244,6 +2249,7 @@ int db8500_prcmu_load_a9wdog(u8 id, u32 timeout)
2244 (u8)((timeout >> 12) & 0xff), 2249 (u8)((timeout >> 12) & 0xff),
2245 (u8)((timeout >> 20) & 0xff)); 2250 (u8)((timeout >> 20) & 0xff));
2246} 2251}
2252EXPORT_SYMBOL(db8500_prcmu_load_a9wdog);
2247 2253
2248/** 2254/**
2249 * prcmu_abb_read() - Read register value(s) from the ABB. 2255 * prcmu_abb_read() - Read register value(s) from the ABB.
@@ -2524,7 +2530,7 @@ static bool read_mailbox_0(void)
2524 2530
2525 for (n = 0; n < NUM_PRCMU_WAKEUPS; n++) { 2531 for (n = 0; n < NUM_PRCMU_WAKEUPS; n++) {
2526 if (ev & prcmu_irq_bit[n]) 2532 if (ev & prcmu_irq_bit[n])
2527 generic_handle_irq(IRQ_PRCMU_BASE + n); 2533 generic_handle_irq(irq_find_mapping(db8500_irq_domain, n));
2528 } 2534 }
2529 r = true; 2535 r = true;
2530 break; 2536 break;
@@ -2737,13 +2743,14 @@ static int db8500_irq_map(struct irq_domain *d, unsigned int virq,
2737} 2743}
2738 2744
2739static struct irq_domain_ops db8500_irq_ops = { 2745static struct irq_domain_ops db8500_irq_ops = {
2740 .map = db8500_irq_map, 2746 .map = db8500_irq_map,
2741 .xlate = irq_domain_xlate_twocell, 2747 .xlate = irq_domain_xlate_twocell,
2742}; 2748};
2743 2749
2744static int db8500_irq_init(struct device_node *np) 2750static int db8500_irq_init(struct device_node *np)
2745{ 2751{
2746 int irq_base = -1; 2752 int irq_base = 0;
2753 int i;
2747 2754
2748 /* In the device tree case, just take some IRQs */ 2755 /* In the device tree case, just take some IRQs */
2749 if (!np) 2756 if (!np)
@@ -2758,6 +2765,10 @@ static int db8500_irq_init(struct device_node *np)
2758 return -ENOSYS; 2765 return -ENOSYS;
2759 } 2766 }
2760 2767
2768 /* All wakeups will be used, so create mappings for all */
2769 for (i = 0; i < NUM_PRCMU_WAKEUPS; i++)
2770 irq_create_mapping(db8500_irq_domain, i);
2771
2761 return 0; 2772 return 0;
2762} 2773}
2763 2774
@@ -3064,6 +3075,11 @@ static struct resource ab8500_resources[] = {
3064 } 3075 }
3065}; 3076};
3066 3077
3078static struct ux500_wdt_data db8500_wdt_pdata = {
3079 .timeout = 600, /* 10 minutes */
3080 .has_28_bits_resolution = true,
3081};
3082
3067static struct mfd_cell db8500_prcmu_devs[] = { 3083static struct mfd_cell db8500_prcmu_devs[] = {
3068 { 3084 {
3069 .name = "db8500-prcmu-regulators", 3085 .name = "db8500-prcmu-regulators",
@@ -3078,6 +3094,12 @@ static struct mfd_cell db8500_prcmu_devs[] = {
3078 .pdata_size = sizeof(db8500_cpufreq_table), 3094 .pdata_size = sizeof(db8500_cpufreq_table),
3079 }, 3095 },
3080 { 3096 {
3097 .name = "ux500_wdt",
3098 .platform_data = &db8500_wdt_pdata,
3099 .pdata_size = sizeof(db8500_wdt_pdata),
3100 .id = -1,
3101 },
3102 {
3081 .name = "ab8500-core", 3103 .name = "ab8500-core",
3082 .of_compatible = "stericsson,ab8500", 3104 .of_compatible = "stericsson,ab8500",
3083 .num_resources = ARRAY_SIZE(ab8500_resources), 3105 .num_resources = ARRAY_SIZE(ab8500_resources),
diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index d9d930302e98..a0cfdf980748 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -75,8 +75,10 @@
75#define ACPIBASE_GCS_OFF 0x3410 75#define ACPIBASE_GCS_OFF 0x3410
76#define ACPIBASE_GCS_END 0x3414 76#define ACPIBASE_GCS_END 0x3414
77 77
78#define GPIOBASE 0x48 78#define GPIOBASE_ICH0 0x58
79#define GPIOCTRL 0x4C 79#define GPIOCTRL_ICH0 0x5C
80#define GPIOBASE_ICH6 0x48
81#define GPIOCTRL_ICH6 0x4C
80 82
81#define RCBABASE 0xf0 83#define RCBABASE 0xf0
82 84
@@ -84,8 +86,17 @@
84#define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i) 86#define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i)
85#define wdt_res(b, i) (&wdt_ich_res[(b) + (i)]) 87#define wdt_res(b, i) (&wdt_ich_res[(b) + (i)])
86 88
87static int lpc_ich_acpi_save = -1; 89struct lpc_ich_cfg {
88static int lpc_ich_gpio_save = -1; 90 int base;
91 int ctrl;
92 int save;
93};
94
95struct lpc_ich_priv {
96 int chipset;
97 struct lpc_ich_cfg acpi;
98 struct lpc_ich_cfg gpio;
99};
89 100
90static struct resource wdt_ich_res[] = { 101static struct resource wdt_ich_res[] = {
91 /* ACPI - TCO */ 102 /* ACPI - TCO */
@@ -661,39 +672,44 @@ MODULE_DEVICE_TABLE(pci, lpc_ich_ids);
661 672
662static void lpc_ich_restore_config_space(struct pci_dev *dev) 673static void lpc_ich_restore_config_space(struct pci_dev *dev)
663{ 674{
664 if (lpc_ich_acpi_save >= 0) { 675 struct lpc_ich_priv *priv = pci_get_drvdata(dev);
665 pci_write_config_byte(dev, ACPICTRL, lpc_ich_acpi_save); 676
666 lpc_ich_acpi_save = -1; 677 if (priv->acpi.save >= 0) {
678 pci_write_config_byte(dev, priv->acpi.ctrl, priv->acpi.save);
679 priv->acpi.save = -1;
667 } 680 }
668 681
669 if (lpc_ich_gpio_save >= 0) { 682 if (priv->gpio.save >= 0) {
670 pci_write_config_byte(dev, GPIOCTRL, lpc_ich_gpio_save); 683 pci_write_config_byte(dev, priv->gpio.ctrl, priv->gpio.save);
671 lpc_ich_gpio_save = -1; 684 priv->gpio.save = -1;
672 } 685 }
673} 686}
674 687
675static void lpc_ich_enable_acpi_space(struct pci_dev *dev) 688static void lpc_ich_enable_acpi_space(struct pci_dev *dev)
676{ 689{
690 struct lpc_ich_priv *priv = pci_get_drvdata(dev);
677 u8 reg_save; 691 u8 reg_save;
678 692
679 pci_read_config_byte(dev, ACPICTRL, &reg_save); 693 pci_read_config_byte(dev, priv->acpi.ctrl, &reg_save);
680 pci_write_config_byte(dev, ACPICTRL, reg_save | 0x10); 694 pci_write_config_byte(dev, priv->acpi.ctrl, reg_save | 0x10);
681 lpc_ich_acpi_save = reg_save; 695 priv->acpi.save = reg_save;
682} 696}
683 697
684static void lpc_ich_enable_gpio_space(struct pci_dev *dev) 698static void lpc_ich_enable_gpio_space(struct pci_dev *dev)
685{ 699{
700 struct lpc_ich_priv *priv = pci_get_drvdata(dev);
686 u8 reg_save; 701 u8 reg_save;
687 702
688 pci_read_config_byte(dev, GPIOCTRL, &reg_save); 703 pci_read_config_byte(dev, priv->gpio.ctrl, &reg_save);
689 pci_write_config_byte(dev, GPIOCTRL, reg_save | 0x10); 704 pci_write_config_byte(dev, priv->gpio.ctrl, reg_save | 0x10);
690 lpc_ich_gpio_save = reg_save; 705 priv->gpio.save = reg_save;
691} 706}
692 707
693static void lpc_ich_finalize_cell(struct mfd_cell *cell, 708static void lpc_ich_finalize_cell(struct pci_dev *dev, struct mfd_cell *cell)
694 const struct pci_device_id *id)
695{ 709{
696 cell->platform_data = &lpc_chipset_info[id->driver_data]; 710 struct lpc_ich_priv *priv = pci_get_drvdata(dev);
711
712 cell->platform_data = &lpc_chipset_info[priv->chipset];
697 cell->pdata_size = sizeof(struct lpc_ich_info); 713 cell->pdata_size = sizeof(struct lpc_ich_info);
698} 714}
699 715
@@ -721,9 +737,9 @@ static int lpc_ich_check_conflict_gpio(struct resource *res)
721 return use_gpio ? use_gpio : ret; 737 return use_gpio ? use_gpio : ret;
722} 738}
723 739
724static int lpc_ich_init_gpio(struct pci_dev *dev, 740static int lpc_ich_init_gpio(struct pci_dev *dev)
725 const struct pci_device_id *id)
726{ 741{
742 struct lpc_ich_priv *priv = pci_get_drvdata(dev);
727 u32 base_addr_cfg; 743 u32 base_addr_cfg;
728 u32 base_addr; 744 u32 base_addr;
729 int ret; 745 int ret;
@@ -731,7 +747,7 @@ static int lpc_ich_init_gpio(struct pci_dev *dev,
731 struct resource *res; 747 struct resource *res;
732 748
733 /* Setup power management base register */ 749 /* Setup power management base register */
734 pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg); 750 pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg);
735 base_addr = base_addr_cfg & 0x0000ff80; 751 base_addr = base_addr_cfg & 0x0000ff80;
736 if (!base_addr) { 752 if (!base_addr) {
737 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); 753 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n");
@@ -757,7 +773,7 @@ static int lpc_ich_init_gpio(struct pci_dev *dev,
757 773
758gpe0_done: 774gpe0_done:
759 /* Setup GPIO base register */ 775 /* Setup GPIO base register */
760 pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); 776 pci_read_config_dword(dev, priv->gpio.base, &base_addr_cfg);
761 base_addr = base_addr_cfg & 0x0000ff80; 777 base_addr = base_addr_cfg & 0x0000ff80;
762 if (!base_addr) { 778 if (!base_addr) {
763 dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n"); 779 dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n");
@@ -768,7 +784,7 @@ gpe0_done:
768 /* Older devices provide fewer GPIO and have a smaller resource size. */ 784 /* Older devices provide fewer GPIO and have a smaller resource size. */
769 res = &gpio_ich_res[ICH_RES_GPIO]; 785 res = &gpio_ich_res[ICH_RES_GPIO];
770 res->start = base_addr; 786 res->start = base_addr;
771 switch (lpc_chipset_info[id->driver_data].gpio_version) { 787 switch (lpc_chipset_info[priv->chipset].gpio_version) {
772 case ICH_V5_GPIO: 788 case ICH_V5_GPIO:
773 case ICH_V10CORP_GPIO: 789 case ICH_V10CORP_GPIO:
774 res->end = res->start + 128 - 1; 790 res->end = res->start + 128 - 1;
@@ -784,10 +800,10 @@ gpe0_done:
784 acpi_conflict = true; 800 acpi_conflict = true;
785 goto gpio_done; 801 goto gpio_done;
786 } 802 }
787 lpc_chipset_info[id->driver_data].use_gpio = ret; 803 lpc_chipset_info[priv->chipset].use_gpio = ret;
788 lpc_ich_enable_gpio_space(dev); 804 lpc_ich_enable_gpio_space(dev);
789 805
790 lpc_ich_finalize_cell(&lpc_ich_cells[LPC_GPIO], id); 806 lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_GPIO]);
791 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO], 807 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO],
792 1, NULL, 0, NULL); 808 1, NULL, 0, NULL);
793 809
@@ -798,16 +814,16 @@ gpio_done:
798 return ret; 814 return ret;
799} 815}
800 816
801static int lpc_ich_init_wdt(struct pci_dev *dev, 817static int lpc_ich_init_wdt(struct pci_dev *dev)
802 const struct pci_device_id *id)
803{ 818{
819 struct lpc_ich_priv *priv = pci_get_drvdata(dev);
804 u32 base_addr_cfg; 820 u32 base_addr_cfg;
805 u32 base_addr; 821 u32 base_addr;
806 int ret; 822 int ret;
807 struct resource *res; 823 struct resource *res;
808 824
809 /* Setup power management base register */ 825 /* Setup power management base register */
810 pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg); 826 pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg);
811 base_addr = base_addr_cfg & 0x0000ff80; 827 base_addr = base_addr_cfg & 0x0000ff80;
812 if (!base_addr) { 828 if (!base_addr) {
813 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); 829 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n");
@@ -830,7 +846,7 @@ static int lpc_ich_init_wdt(struct pci_dev *dev,
830 * we have to read RCBA from PCI Config space 0xf0 and use 846 * we have to read RCBA from PCI Config space 0xf0 and use
831 * it as base. GCS = RCBA + ICH6_GCS(0x3410). 847 * it as base. GCS = RCBA + ICH6_GCS(0x3410).
832 */ 848 */
833 if (lpc_chipset_info[id->driver_data].iTCO_version == 1) { 849 if (lpc_chipset_info[priv->chipset].iTCO_version == 1) {
834 /* Don't register iomem for TCO ver 1 */ 850 /* Don't register iomem for TCO ver 1 */
835 lpc_ich_cells[LPC_WDT].num_resources--; 851 lpc_ich_cells[LPC_WDT].num_resources--;
836 } else { 852 } else {
@@ -847,7 +863,7 @@ static int lpc_ich_init_wdt(struct pci_dev *dev,
847 res->end = base_addr + ACPIBASE_GCS_END; 863 res->end = base_addr + ACPIBASE_GCS_END;
848 } 864 }
849 865
850 lpc_ich_finalize_cell(&lpc_ich_cells[LPC_WDT], id); 866 lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_WDT]);
851 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT], 867 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT],
852 1, NULL, 0, NULL); 868 1, NULL, 0, NULL);
853 869
@@ -858,14 +874,35 @@ wdt_done:
858static int lpc_ich_probe(struct pci_dev *dev, 874static int lpc_ich_probe(struct pci_dev *dev,
859 const struct pci_device_id *id) 875 const struct pci_device_id *id)
860{ 876{
877 struct lpc_ich_priv *priv;
861 int ret; 878 int ret;
862 bool cell_added = false; 879 bool cell_added = false;
863 880
864 ret = lpc_ich_init_wdt(dev, id); 881 priv = kmalloc(GFP_KERNEL, sizeof(struct lpc_ich_priv));
882 if (!priv)
883 return -ENOMEM;
884
885 priv->chipset = id->driver_data;
886 priv->acpi.save = -1;
887 priv->acpi.base = ACPIBASE;
888 priv->acpi.ctrl = ACPICTRL;
889
890 priv->gpio.save = -1;
891 if (priv->chipset <= LPC_ICH5) {
892 priv->gpio.base = GPIOBASE_ICH0;
893 priv->gpio.ctrl = GPIOCTRL_ICH0;
894 } else {
895 priv->gpio.base = GPIOBASE_ICH6;
896 priv->gpio.ctrl = GPIOCTRL_ICH6;
897 }
898
899 pci_set_drvdata(dev, priv);
900
901 ret = lpc_ich_init_wdt(dev);
865 if (!ret) 902 if (!ret)
866 cell_added = true; 903 cell_added = true;
867 904
868 ret = lpc_ich_init_gpio(dev, id); 905 ret = lpc_ich_init_gpio(dev);
869 if (!ret) 906 if (!ret)
870 cell_added = true; 907 cell_added = true;
871 908
@@ -876,6 +913,8 @@ static int lpc_ich_probe(struct pci_dev *dev,
876 if (!cell_added) { 913 if (!cell_added) {
877 dev_warn(&dev->dev, "No MFD cells added\n"); 914 dev_warn(&dev->dev, "No MFD cells added\n");
878 lpc_ich_restore_config_space(dev); 915 lpc_ich_restore_config_space(dev);
916 pci_set_drvdata(dev, NULL);
917 kfree(priv);
879 return -ENODEV; 918 return -ENODEV;
880 } 919 }
881 920
@@ -884,8 +923,12 @@ static int lpc_ich_probe(struct pci_dev *dev,
884 923
885static void lpc_ich_remove(struct pci_dev *dev) 924static void lpc_ich_remove(struct pci_dev *dev)
886{ 925{
926 void *priv = pci_get_drvdata(dev);
927
887 mfd_remove_devices(&dev->dev); 928 mfd_remove_devices(&dev->dev);
888 lpc_ich_restore_config_space(dev); 929 lpc_ich_restore_config_space(dev);
930 pci_set_drvdata(dev, NULL);
931 kfree(priv);
889} 932}
890 933
891static struct pci_driver lpc_ich_driver = { 934static struct pci_driver lpc_ich_driver = {
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index f6878f8db57d..4d73963cd8f0 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -93,15 +93,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
93 if (max77686 == NULL) 93 if (max77686 == NULL)
94 return -ENOMEM; 94 return -ENOMEM;
95 95
96 max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
97 if (IS_ERR(max77686->regmap)) {
98 ret = PTR_ERR(max77686->regmap);
99 dev_err(max77686->dev, "Failed to allocate register map: %d\n",
100 ret);
101 kfree(max77686);
102 return ret;
103 }
104
105 i2c_set_clientdata(i2c, max77686); 96 i2c_set_clientdata(i2c, max77686);
106 max77686->dev = &i2c->dev; 97 max77686->dev = &i2c->dev;
107 max77686->i2c = i2c; 98 max77686->i2c = i2c;
@@ -111,6 +102,15 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
111 max77686->irq_gpio = pdata->irq_gpio; 102 max77686->irq_gpio = pdata->irq_gpio;
112 max77686->irq = i2c->irq; 103 max77686->irq = i2c->irq;
113 104
105 max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
106 if (IS_ERR(max77686->regmap)) {
107 ret = PTR_ERR(max77686->regmap);
108 dev_err(max77686->dev, "Failed to allocate register map: %d\n",
109 ret);
110 kfree(max77686);
111 return ret;
112 }
113
114 if (regmap_read(max77686->regmap, 114 if (regmap_read(max77686->regmap,
115 MAX77686_REG_DEVICE_ID, &data) < 0) { 115 MAX77686_REG_DEVICE_ID, &data) < 0) {
116 dev_err(max77686->dev, 116 dev_err(max77686->dev,
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index cc5155e20494..9e60fed5ff82 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -114,35 +114,37 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
114 u8 reg_data; 114 u8 reg_data;
115 int ret = 0; 115 int ret = 0;
116 116
117 if (!pdata) {
118 dev_err(&i2c->dev, "No platform data found.\n");
119 return -EINVAL;
120 }
121
117 max77693 = devm_kzalloc(&i2c->dev, 122 max77693 = devm_kzalloc(&i2c->dev,
118 sizeof(struct max77693_dev), GFP_KERNEL); 123 sizeof(struct max77693_dev), GFP_KERNEL);
119 if (max77693 == NULL) 124 if (max77693 == NULL)
120 return -ENOMEM; 125 return -ENOMEM;
121 126
122 max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
123 if (IS_ERR(max77693->regmap)) {
124 ret = PTR_ERR(max77693->regmap);
125 dev_err(max77693->dev,"failed to allocate register map: %d\n",
126 ret);
127 goto err_regmap;
128 }
129
130 i2c_set_clientdata(i2c, max77693); 127 i2c_set_clientdata(i2c, max77693);
131 max77693->dev = &i2c->dev; 128 max77693->dev = &i2c->dev;
132 max77693->i2c = i2c; 129 max77693->i2c = i2c;
133 max77693->irq = i2c->irq; 130 max77693->irq = i2c->irq;
134 max77693->type = id->driver_data; 131 max77693->type = id->driver_data;
135 132
136 if (!pdata) 133 max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
137 goto err_regmap; 134 if (IS_ERR(max77693->regmap)) {
135 ret = PTR_ERR(max77693->regmap);
136 dev_err(max77693->dev, "failed to allocate register map: %d\n",
137 ret);
138 return ret;
139 }
138 140
139 max77693->wakeup = pdata->wakeup; 141 max77693->wakeup = pdata->wakeup;
140 142
141 if (max77693_read_reg(max77693->regmap, 143 ret = max77693_read_reg(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2,
142 MAX77693_PMIC_REG_PMIC_ID2, &reg_data) < 0) { 144 &reg_data);
145 if (ret < 0) {
143 dev_err(max77693->dev, "device not found on this channel\n"); 146 dev_err(max77693->dev, "device not found on this channel\n");
144 ret = -ENODEV; 147 return ret;
145 goto err_regmap;
146 } else 148 } else
147 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); 149 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);
148 150
@@ -163,7 +165,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
163 ret = PTR_ERR(max77693->regmap_muic); 165 ret = PTR_ERR(max77693->regmap_muic);
164 dev_err(max77693->dev, 166 dev_err(max77693->dev,
165 "failed to allocate register map: %d\n", ret); 167 "failed to allocate register map: %d\n", ret);
166 goto err_regmap; 168 goto err_regmap_muic;
167 } 169 }
168 170
169 ret = max77693_irq_init(max77693); 171 ret = max77693_irq_init(max77693);
@@ -184,9 +186,9 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
184err_mfd: 186err_mfd:
185 max77693_irq_exit(max77693); 187 max77693_irq_exit(max77693);
186err_irq: 188err_irq:
189err_regmap_muic:
187 i2c_unregister_device(max77693->muic); 190 i2c_unregister_device(max77693->muic);
188 i2c_unregister_device(max77693->haptic); 191 i2c_unregister_device(max77693->haptic);
189err_regmap:
190 return ret; 192 return ret;
191} 193}
192 194
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index e32466e865b9..f0cc40296d8c 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -14,10 +14,13 @@
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/irqdomain.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/regulator/machine.h> 19#include <linux/regulator/machine.h>
19#include <linux/mfd/core.h> 20#include <linux/mfd/core.h>
20#include <linux/mfd/max8925.h> 21#include <linux/mfd/max8925.h>
22#include <linux/of.h>
23#include <linux/of_platform.h>
21 24
22static struct resource bk_resources[] = { 25static struct resource bk_resources[] = {
23 { 0x84, 0x84, "mode control", IORESOURCE_REG, }, 26 { 0x84, 0x84, "mode control", IORESOURCE_REG, },
@@ -639,17 +642,33 @@ static struct irq_chip max8925_irq_chip = {
639 .irq_disable = max8925_irq_disable, 642 .irq_disable = max8925_irq_disable,
640}; 643};
641 644
645static int max8925_irq_domain_map(struct irq_domain *d, unsigned int virq,
646 irq_hw_number_t hw)
647{
648 irq_set_chip_data(virq, d->host_data);
649 irq_set_chip_and_handler(virq, &max8925_irq_chip, handle_edge_irq);
650 irq_set_nested_thread(virq, 1);
651#ifdef CONFIG_ARM
652 set_irq_flags(virq, IRQF_VALID);
653#else
654 irq_set_noprobe(virq);
655#endif
656 return 0;
657}
658
659static struct irq_domain_ops max8925_irq_domain_ops = {
660 .map = max8925_irq_domain_map,
661 .xlate = irq_domain_xlate_onetwocell,
662};
663
664
642static int max8925_irq_init(struct max8925_chip *chip, int irq, 665static int max8925_irq_init(struct max8925_chip *chip, int irq,
643 struct max8925_platform_data *pdata) 666 struct max8925_platform_data *pdata)
644{ 667{
645 unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; 668 unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
646 int i, ret; 669 int ret;
647 int __irq; 670 struct device_node *node = chip->dev->of_node;
648 671
649 if (!pdata || !pdata->irq_base) {
650 dev_warn(chip->dev, "No interrupt support on IRQ base\n");
651 return -EINVAL;
652 }
653 /* clear all interrupts */ 672 /* clear all interrupts */
654 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ1); 673 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ1);
655 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ2); 674 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ2);
@@ -667,35 +686,30 @@ static int max8925_irq_init(struct max8925_chip *chip, int irq,
667 max8925_reg_write(chip->rtc, MAX8925_RTC_IRQ_MASK, 0xff); 686 max8925_reg_write(chip->rtc, MAX8925_RTC_IRQ_MASK, 0xff);
668 687
669 mutex_init(&chip->irq_lock); 688 mutex_init(&chip->irq_lock);
670 chip->core_irq = irq; 689 chip->irq_base = irq_alloc_descs(-1, 0, MAX8925_NR_IRQS, 0);
671 chip->irq_base = pdata->irq_base; 690 if (chip->irq_base < 0) {
672 691 dev_err(chip->dev, "Failed to allocate interrupts, ret:%d\n",
673 /* register with genirq */ 692 chip->irq_base);
674 for (i = 0; i < ARRAY_SIZE(max8925_irqs); i++) { 693 return -EBUSY;
675 __irq = i + chip->irq_base;
676 irq_set_chip_data(__irq, chip);
677 irq_set_chip_and_handler(__irq, &max8925_irq_chip,
678 handle_edge_irq);
679 irq_set_nested_thread(__irq, 1);
680#ifdef CONFIG_ARM
681 set_irq_flags(__irq, IRQF_VALID);
682#else
683 irq_set_noprobe(__irq);
684#endif
685 }
686 if (!irq) {
687 dev_warn(chip->dev, "No interrupt support on core IRQ\n");
688 goto tsc_irq;
689 } 694 }
690 695
696 irq_domain_add_legacy(node, MAX8925_NR_IRQS, chip->irq_base, 0,
697 &max8925_irq_domain_ops, chip);
698
699 /* request irq handler for pmic main irq*/
700 chip->core_irq = irq;
701 if (!chip->core_irq)
702 return -EBUSY;
691 ret = request_threaded_irq(irq, NULL, max8925_irq, flags | IRQF_ONESHOT, 703 ret = request_threaded_irq(irq, NULL, max8925_irq, flags | IRQF_ONESHOT,
692 "max8925", chip); 704 "max8925", chip);
693 if (ret) { 705 if (ret) {
694 dev_err(chip->dev, "Failed to request core IRQ: %d\n", ret); 706 dev_err(chip->dev, "Failed to request core IRQ: %d\n", ret);
695 chip->core_irq = 0; 707 chip->core_irq = 0;
708 return -EBUSY;
696 } 709 }
697 710
698tsc_irq: 711 /* request irq handler for pmic tsc irq*/
712
699 /* mask TSC interrupt */ 713 /* mask TSC interrupt */
700 max8925_reg_write(chip->adc, MAX8925_TSC_IRQ_MASK, 0x0f); 714 max8925_reg_write(chip->adc, MAX8925_TSC_IRQ_MASK, 0x0f);
701 715
@@ -704,7 +718,6 @@ tsc_irq:
704 return 0; 718 return 0;
705 } 719 }
706 chip->tsc_irq = pdata->tsc_irq; 720 chip->tsc_irq = pdata->tsc_irq;
707
708 ret = request_threaded_irq(chip->tsc_irq, NULL, max8925_tsc_irq, 721 ret = request_threaded_irq(chip->tsc_irq, NULL, max8925_tsc_irq,
709 flags | IRQF_ONESHOT, "max8925-tsc", chip); 722 flags | IRQF_ONESHOT, "max8925-tsc", chip);
710 if (ret) { 723 if (ret) {
@@ -846,7 +859,7 @@ int max8925_device_init(struct max8925_chip *chip,
846 859
847 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 860 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
848 ARRAY_SIZE(rtc_devs), 861 ARRAY_SIZE(rtc_devs),
849 &rtc_resources[0], chip->irq_base, NULL); 862 NULL, chip->irq_base, NULL);
850 if (ret < 0) { 863 if (ret < 0) {
851 dev_err(chip->dev, "Failed to add rtc subdev\n"); 864 dev_err(chip->dev, "Failed to add rtc subdev\n");
852 goto out; 865 goto out;
@@ -854,7 +867,7 @@ int max8925_device_init(struct max8925_chip *chip,
854 867
855 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], 868 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
856 ARRAY_SIZE(onkey_devs), 869 ARRAY_SIZE(onkey_devs),
857 &onkey_resources[0], 0, NULL); 870 NULL, chip->irq_base, NULL);
858 if (ret < 0) { 871 if (ret < 0) {
859 dev_err(chip->dev, "Failed to add onkey subdev\n"); 872 dev_err(chip->dev, "Failed to add onkey subdev\n");
860 goto out_dev; 873 goto out_dev;
@@ -873,21 +886,19 @@ int max8925_device_init(struct max8925_chip *chip,
873 goto out_dev; 886 goto out_dev;
874 } 887 }
875 888
876 if (pdata && pdata->power) { 889 ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
877 ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 890 ARRAY_SIZE(power_devs),
878 ARRAY_SIZE(power_devs), 891 NULL, 0, NULL);
879 &power_supply_resources[0], 0, NULL); 892 if (ret < 0) {
880 if (ret < 0) { 893 dev_err(chip->dev,
881 dev_err(chip->dev, "Failed to add power supply " 894 "Failed to add power supply subdev, err = %d\n", ret);
882 "subdev\n"); 895 goto out_dev;
883 goto out_dev;
884 }
885 } 896 }
886 897
887 if (pdata && pdata->touch) { 898 if (pdata && pdata->touch) {
888 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0], 899 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
889 ARRAY_SIZE(touch_devs), 900 ARRAY_SIZE(touch_devs),
890 &touch_resources[0], 0, NULL); 901 NULL, chip->tsc_irq, NULL);
891 if (ret < 0) { 902 if (ret < 0) {
892 dev_err(chip->dev, "Failed to add touch subdev\n"); 903 dev_err(chip->dev, "Failed to add touch subdev\n");
893 goto out_dev; 904 goto out_dev;
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 00b5b456063d..92bbebd31598 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -135,13 +135,37 @@ static const struct i2c_device_id max8925_id_table[] = {
135}; 135};
136MODULE_DEVICE_TABLE(i2c, max8925_id_table); 136MODULE_DEVICE_TABLE(i2c, max8925_id_table);
137 137
138static int max8925_dt_init(struct device_node *np, struct device *dev,
139 struct max8925_platform_data *pdata)
140{
141 int ret;
142
143 ret = of_property_read_u32(np, "maxim,tsc-irq", &pdata->tsc_irq);
144 if (ret) {
145 dev_err(dev, "Not found maxim,tsc-irq property\n");
146 return -EINVAL;
147 }
148 return 0;
149}
150
138static int max8925_probe(struct i2c_client *client, 151static int max8925_probe(struct i2c_client *client,
139 const struct i2c_device_id *id) 152 const struct i2c_device_id *id)
140{ 153{
141 struct max8925_platform_data *pdata = client->dev.platform_data; 154 struct max8925_platform_data *pdata = client->dev.platform_data;
142 static struct max8925_chip *chip; 155 static struct max8925_chip *chip;
143 156 struct device_node *node = client->dev.of_node;
144 if (!pdata) { 157
158 if (node && !pdata) {
159 /* parse DT to get platform data */
160 pdata = devm_kzalloc(&client->dev,
161 sizeof(struct max8925_platform_data),
162 GFP_KERNEL);
163 if (!pdata)
164 return -ENOMEM;
165
166 if (max8925_dt_init(node, &client->dev, pdata))
167 return -EINVAL;
168 } else if (!pdata) {
145 pr_info("%s: platform data is missing\n", __func__); 169 pr_info("%s: platform data is missing\n", __func__);
146 return -EINVAL; 170 return -EINVAL;
147 } 171 }
@@ -203,11 +227,18 @@ static int max8925_resume(struct device *dev)
203 227
204static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume); 228static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume);
205 229
230static const struct of_device_id max8925_dt_ids[] = {
231 { .compatible = "maxim,max8925", },
232 {},
233};
234MODULE_DEVICE_TABLE(of, max8925_dt_ids);
235
206static struct i2c_driver max8925_driver = { 236static struct i2c_driver max8925_driver = {
207 .driver = { 237 .driver = {
208 .name = "max8925", 238 .name = "max8925",
209 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
210 .pm = &max8925_pm_ops, 240 .pm = &max8925_pm_ops,
241 .of_match_table = of_match_ptr(max8925_dt_ids),
211 }, 242 },
212 .probe = max8925_probe, 243 .probe = max8925_probe,
213 .remove = max8925_remove, 244 .remove = max8925_remove,
@@ -217,7 +248,6 @@ static struct i2c_driver max8925_driver = {
217static int __init max8925_i2c_init(void) 248static int __init max8925_i2c_init(void)
218{ 249{
219 int ret; 250 int ret;
220
221 ret = i2c_add_driver(&max8925_driver); 251 ret = i2c_add_driver(&max8925_driver);
222 if (ret != 0) 252 if (ret != 0)
223 pr_err("Failed to register MAX8925 I2C driver: %d\n", ret); 253 pr_err("Failed to register MAX8925 I2C driver: %d\n", ret);
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 6ffd7a2affdc..bbdbc50a3cca 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -39,6 +39,14 @@ enum palmas_ids {
39 PALMAS_USB_ID, 39 PALMAS_USB_ID,
40}; 40};
41 41
42static struct resource palmas_rtc_resources[] = {
43 {
44 .start = PALMAS_RTC_ALARM_IRQ,
45 .end = PALMAS_RTC_ALARM_IRQ,
46 .flags = IORESOURCE_IRQ,
47 },
48};
49
42static const struct mfd_cell palmas_children[] = { 50static const struct mfd_cell palmas_children[] = {
43 { 51 {
44 .name = "palmas-pmic", 52 .name = "palmas-pmic",
@@ -59,6 +67,8 @@ static const struct mfd_cell palmas_children[] = {
59 { 67 {
60 .name = "palmas-rtc", 68 .name = "palmas-rtc",
61 .id = PALMAS_RTC_ID, 69 .id = PALMAS_RTC_ID,
70 .resources = &palmas_rtc_resources[0],
71 .num_resources = ARRAY_SIZE(palmas_rtc_resources),
62 }, 72 },
63 { 73 {
64 .name = "palmas-pwrbutton", 74 .name = "palmas-pwrbutton",
@@ -456,8 +466,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
456 466
457 ret = mfd_add_devices(palmas->dev, -1, 467 ret = mfd_add_devices(palmas->dev, -1,
458 children, ARRAY_SIZE(palmas_children), 468 children, ARRAY_SIZE(palmas_children),
459 NULL, regmap_irq_chip_get_base(palmas->irq_data), 469 NULL, 0,
460 NULL); 470 regmap_irq_get_domain(palmas->irq_data));
461 kfree(children); 471 kfree(children);
462 472
463 if (ret < 0) 473 if (ret < 0)
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 64803f13bcec..d11567307fbe 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -208,6 +208,8 @@ static int pcf50633_probe(struct i2c_client *client,
208 if (!pcf) 208 if (!pcf)
209 return -ENOMEM; 209 return -ENOMEM;
210 210
211 i2c_set_clientdata(client, pcf);
212 pcf->dev = &client->dev;
211 pcf->pdata = pdata; 213 pcf->pdata = pdata;
212 214
213 mutex_init(&pcf->lock); 215 mutex_init(&pcf->lock);
@@ -219,9 +221,6 @@ static int pcf50633_probe(struct i2c_client *client,
219 return ret; 221 return ret;
220 } 222 }
221 223
222 i2c_set_clientdata(client, pcf);
223 pcf->dev = &client->dev;
224
225 version = pcf50633_reg_read(pcf, 0); 224 version = pcf50633_reg_read(pcf, 0);
226 variant = pcf50633_reg_read(pcf, 1); 225 variant = pcf50633_reg_read(pcf, 1);
227 if (version < 0 || variant < 0) { 226 if (version < 0 || variant < 0) {
diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index 89f046ca9e41..2a2d31687b72 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -112,6 +112,31 @@ static int rtl8411_card_power_off(struct rtsx_pcr *pcr, int card)
112 BPP_LDO_POWB, BPP_LDO_SUSPEND); 112 BPP_LDO_POWB, BPP_LDO_SUSPEND);
113} 113}
114 114
115static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
116{
117 u8 mask, val;
118 int err;
119
120 mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK;
121 if (voltage == OUTPUT_3V3) {
122 err = rtsx_pci_write_register(pcr,
123 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D);
124 if (err < 0)
125 return err;
126 val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3;
127 } else if (voltage == OUTPUT_1V8) {
128 err = rtsx_pci_write_register(pcr,
129 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B);
130 if (err < 0)
131 return err;
132 val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8;
133 } else {
134 return -EINVAL;
135 }
136
137 return rtsx_pci_write_register(pcr, LDO_CTL, mask, val);
138}
139
115static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr) 140static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr)
116{ 141{
117 unsigned int card_exist; 142 unsigned int card_exist;
@@ -163,6 +188,18 @@ static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr)
163 return card_exist; 188 return card_exist;
164} 189}
165 190
191static int rtl8411_conv_clk_and_div_n(int input, int dir)
192{
193 int output;
194
195 if (dir == CLK_TO_DIV_N)
196 output = input * 4 / 5 - 2;
197 else
198 output = (input + 2) * 5 / 4;
199
200 return output;
201}
202
166static const struct pcr_ops rtl8411_pcr_ops = { 203static const struct pcr_ops rtl8411_pcr_ops = {
167 .extra_init_hw = rtl8411_extra_init_hw, 204 .extra_init_hw = rtl8411_extra_init_hw,
168 .optimize_phy = NULL, 205 .optimize_phy = NULL,
@@ -172,7 +209,9 @@ static const struct pcr_ops rtl8411_pcr_ops = {
172 .disable_auto_blink = rtl8411_disable_auto_blink, 209 .disable_auto_blink = rtl8411_disable_auto_blink,
173 .card_power_on = rtl8411_card_power_on, 210 .card_power_on = rtl8411_card_power_on,
174 .card_power_off = rtl8411_card_power_off, 211 .card_power_off = rtl8411_card_power_off,
212 .switch_output_voltage = rtl8411_switch_output_voltage,
175 .cd_deglitch = rtl8411_cd_deglitch, 213 .cd_deglitch = rtl8411_cd_deglitch,
214 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
176}; 215};
177 216
178/* SD Pull Control Enable: 217/* SD Pull Control Enable:
diff --git a/drivers/mfd/rts5209.c b/drivers/mfd/rts5209.c
index 283a4f148084..ec78d9fb0879 100644
--- a/drivers/mfd/rts5209.c
+++ b/drivers/mfd/rts5209.c
@@ -144,6 +144,33 @@ static int rts5209_card_power_off(struct rtsx_pcr *pcr, int card)
144 return rtsx_pci_send_cmd(pcr, 100); 144 return rtsx_pci_send_cmd(pcr, 100);
145} 145}
146 146
147static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
148{
149 int err;
150
151 if (voltage == OUTPUT_3V3) {
152 err = rtsx_pci_write_register(pcr,
153 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D);
154 if (err < 0)
155 return err;
156 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
157 if (err < 0)
158 return err;
159 } else if (voltage == OUTPUT_1V8) {
160 err = rtsx_pci_write_register(pcr,
161 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B);
162 if (err < 0)
163 return err;
164 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
165 if (err < 0)
166 return err;
167 } else {
168 return -EINVAL;
169 }
170
171 return 0;
172}
173
147static const struct pcr_ops rts5209_pcr_ops = { 174static const struct pcr_ops rts5209_pcr_ops = {
148 .extra_init_hw = rts5209_extra_init_hw, 175 .extra_init_hw = rts5209_extra_init_hw,
149 .optimize_phy = rts5209_optimize_phy, 176 .optimize_phy = rts5209_optimize_phy,
@@ -153,7 +180,9 @@ static const struct pcr_ops rts5209_pcr_ops = {
153 .disable_auto_blink = rts5209_disable_auto_blink, 180 .disable_auto_blink = rts5209_disable_auto_blink,
154 .card_power_on = rts5209_card_power_on, 181 .card_power_on = rts5209_card_power_on,
155 .card_power_off = rts5209_card_power_off, 182 .card_power_off = rts5209_card_power_off,
183 .switch_output_voltage = rts5209_switch_output_voltage,
156 .cd_deglitch = NULL, 184 .cd_deglitch = NULL,
185 .conv_clk_and_div_n = NULL,
157}; 186};
158 187
159/* SD Pull Control Enable: 188/* SD Pull Control Enable:
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
new file mode 100644
index 000000000000..fc831dcb1480
--- /dev/null
+++ b/drivers/mfd/rts5227.c
@@ -0,0 +1,234 @@
1/* Driver for Realtek PCI-Express card reader
2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
8 * later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 *
22 * Roger Tseng <rogerable@realtek.com>
23 * No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan
24 */
25
26#include <linux/module.h>
27#include <linux/delay.h>
28#include <linux/mfd/rtsx_pci.h>
29
30#include "rtsx_pcr.h"
31
32static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
33{
34 u16 cap;
35
36 rtsx_pci_init_cmd(pcr);
37
38 /* Configure GPIO as output */
39 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02);
40 /* Switch LDO3318 source from DV33 to card_3v3 */
41 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00);
42 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01);
43 /* LED shine disabled, set initial shine cycle period */
44 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02);
45 /* Configure LTR */
46 pcie_capability_read_word(pcr->pci, PCI_EXP_DEVCTL2, &cap);
47 if (cap & PCI_EXP_LTR_EN)
48 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LTR_CTL, 0xFF, 0xA3);
49 /* Configure OBFF */
50 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OBFF_CFG, 0x03, 0x03);
51 /* Configure force_clock_req
52 * Maybe We should define 0xFF03 as some name
53 */
54 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 0xFF03, 0x08, 0x08);
55 /* Correct driving */
56 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
57 SD30_CLK_DRIVE_SEL, 0xFF, 0x96);
58 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
59 SD30_CMD_DRIVE_SEL, 0xFF, 0x96);
60 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
61 SD30_DAT_DRIVE_SEL, 0xFF, 0x96);
62
63 return rtsx_pci_send_cmd(pcr, 100);
64}
65
66static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
67{
68 /* Optimize RX sensitivity */
69 return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42);
70}
71
72static int rts5227_turn_on_led(struct rtsx_pcr *pcr)
73{
74 return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x02);
75}
76
77static int rts5227_turn_off_led(struct rtsx_pcr *pcr)
78{
79 return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x00);
80}
81
82static int rts5227_enable_auto_blink(struct rtsx_pcr *pcr)
83{
84 return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x08);
85}
86
87static int rts5227_disable_auto_blink(struct rtsx_pcr *pcr)
88{
89 return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x00);
90}
91
92static int rts5227_card_power_on(struct rtsx_pcr *pcr, int card)
93{
94 int err;
95
96 rtsx_pci_init_cmd(pcr);
97 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
98 SD_POWER_MASK, SD_PARTIAL_POWER_ON);
99 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
100 LDO3318_PWR_MASK, 0x02);
101 err = rtsx_pci_send_cmd(pcr, 100);
102 if (err < 0)
103 return err;
104
105 /* To avoid too large in-rush current */
106 udelay(150);
107
108 rtsx_pci_init_cmd(pcr);
109 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
110 SD_POWER_MASK, SD_POWER_ON);
111 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
112 LDO3318_PWR_MASK, 0x06);
113 err = rtsx_pci_send_cmd(pcr, 100);
114 if (err < 0)
115 return err;
116
117 return 0;
118}
119
120static int rts5227_card_power_off(struct rtsx_pcr *pcr, int card)
121{
122 rtsx_pci_init_cmd(pcr);
123 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
124 SD_POWER_MASK | PMOS_STRG_MASK,
125 SD_POWER_OFF | PMOS_STRG_400mA);
126 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
127 LDO3318_PWR_MASK, 0X00);
128 return rtsx_pci_send_cmd(pcr, 100);
129}
130
131static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
132{
133 int err;
134 u8 drive_sel;
135
136 if (voltage == OUTPUT_3V3) {
137 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
138 if (err < 0)
139 return err;
140 drive_sel = 0x96;
141 } else if (voltage == OUTPUT_1V8) {
142 err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02);
143 if (err < 0)
144 return err;
145 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C80 | 0x24);
146 if (err < 0)
147 return err;
148 drive_sel = 0xB3;
149 } else {
150 return -EINVAL;
151 }
152
153 /* set pad drive */
154 rtsx_pci_init_cmd(pcr);
155 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL,
156 0xFF, drive_sel);
157 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL,
158 0xFF, drive_sel);
159 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL,
160 0xFF, drive_sel);
161 return rtsx_pci_send_cmd(pcr, 100);
162}
163
164static const struct pcr_ops rts5227_pcr_ops = {
165 .extra_init_hw = rts5227_extra_init_hw,
166 .optimize_phy = rts5227_optimize_phy,
167 .turn_on_led = rts5227_turn_on_led,
168 .turn_off_led = rts5227_turn_off_led,
169 .enable_auto_blink = rts5227_enable_auto_blink,
170 .disable_auto_blink = rts5227_disable_auto_blink,
171 .card_power_on = rts5227_card_power_on,
172 .card_power_off = rts5227_card_power_off,
173 .switch_output_voltage = rts5227_switch_output_voltage,
174 .cd_deglitch = NULL,
175 .conv_clk_and_div_n = NULL,
176};
177
178/* SD Pull Control Enable:
179 * SD_DAT[3:0] ==> pull up
180 * SD_CD ==> pull up
181 * SD_WP ==> pull up
182 * SD_CMD ==> pull up
183 * SD_CLK ==> pull down
184 */
185static const u32 rts5227_sd_pull_ctl_enable_tbl[] = {
186 RTSX_REG_PAIR(CARD_PULL_CTL2, 0xAA),
187 RTSX_REG_PAIR(CARD_PULL_CTL3, 0xE9),
188 0,
189};
190
191/* SD Pull Control Disable:
192 * SD_DAT[3:0] ==> pull down
193 * SD_CD ==> pull up
194 * SD_WP ==> pull down
195 * SD_CMD ==> pull down
196 * SD_CLK ==> pull down
197 */
198static const u32 rts5227_sd_pull_ctl_disable_tbl[] = {
199 RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
200 RTSX_REG_PAIR(CARD_PULL_CTL3, 0xD5),
201 0,
202};
203
204/* MS Pull Control Enable:
205 * MS CD ==> pull up
206 * others ==> pull down
207 */
208static const u32 rts5227_ms_pull_ctl_enable_tbl[] = {
209 RTSX_REG_PAIR(CARD_PULL_CTL5, 0x55),
210 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x15),
211 0,
212};
213
214/* MS Pull Control Disable:
215 * MS CD ==> pull up
216 * others ==> pull down
217 */
218static const u32 rts5227_ms_pull_ctl_disable_tbl[] = {
219 RTSX_REG_PAIR(CARD_PULL_CTL5, 0x55),
220 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x15),
221 0,
222};
223
224void rts5227_init_params(struct rtsx_pcr *pcr)
225{
226 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104;
227 pcr->num_slots = 2;
228 pcr->ops = &rts5227_pcr_ops;
229
230 pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl;
231 pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl;
232 pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl;
233 pcr->ms_pull_ctl_disable_tbl = rts5227_ms_pull_ctl_disable_tbl;
234}
diff --git a/drivers/mfd/rts5229.c b/drivers/mfd/rts5229.c
index b9dbab266fda..58af4dbe3586 100644
--- a/drivers/mfd/rts5229.c
+++ b/drivers/mfd/rts5229.c
@@ -114,6 +114,33 @@ static int rts5229_card_power_off(struct rtsx_pcr *pcr, int card)
114 return rtsx_pci_send_cmd(pcr, 100); 114 return rtsx_pci_send_cmd(pcr, 100);
115} 115}
116 116
117static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
118{
119 int err;
120
121 if (voltage == OUTPUT_3V3) {
122 err = rtsx_pci_write_register(pcr,
123 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D);
124 if (err < 0)
125 return err;
126 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
127 if (err < 0)
128 return err;
129 } else if (voltage == OUTPUT_1V8) {
130 err = rtsx_pci_write_register(pcr,
131 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B);
132 if (err < 0)
133 return err;
134 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
135 if (err < 0)
136 return err;
137 } else {
138 return -EINVAL;
139 }
140
141 return 0;
142}
143
117static const struct pcr_ops rts5229_pcr_ops = { 144static const struct pcr_ops rts5229_pcr_ops = {
118 .extra_init_hw = rts5229_extra_init_hw, 145 .extra_init_hw = rts5229_extra_init_hw,
119 .optimize_phy = rts5229_optimize_phy, 146 .optimize_phy = rts5229_optimize_phy,
@@ -123,7 +150,9 @@ static const struct pcr_ops rts5229_pcr_ops = {
123 .disable_auto_blink = rts5229_disable_auto_blink, 150 .disable_auto_blink = rts5229_disable_auto_blink,
124 .card_power_on = rts5229_card_power_on, 151 .card_power_on = rts5229_card_power_on,
125 .card_power_off = rts5229_card_power_off, 152 .card_power_off = rts5229_card_power_off,
153 .switch_output_voltage = rts5229_switch_output_voltage,
126 .cd_deglitch = NULL, 154 .cd_deglitch = NULL,
155 .conv_clk_and_div_n = NULL,
127}; 156};
128 157
129/* SD Pull Control Enable: 158/* SD Pull Control Enable:
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 7a7b0bda4618..822237e322ba 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -55,6 +55,7 @@ static DEFINE_PCI_DEVICE_TABLE(rtsx_pci_ids) = {
55 { PCI_DEVICE(0x10EC, 0x5209), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 55 { PCI_DEVICE(0x10EC, 0x5209), PCI_CLASS_OTHERS << 16, 0xFF0000 },
56 { PCI_DEVICE(0x10EC, 0x5229), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 56 { PCI_DEVICE(0x10EC, 0x5229), PCI_CLASS_OTHERS << 16, 0xFF0000 },
57 { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 57 { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 },
58 { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 },
58 { 0, } 59 { 0, }
59}; 60};
60 61
@@ -325,7 +326,6 @@ static void rtsx_pci_add_sg_tbl(struct rtsx_pcr *pcr,
325 val = ((u64)addr << 32) | ((u64)len << 12) | option; 326 val = ((u64)addr << 32) | ((u64)len << 12) | option;
326 327
327 put_unaligned_le64(val, ptr); 328 put_unaligned_le64(val, ptr);
328 ptr++;
329 pcr->sgi++; 329 pcr->sgi++;
330} 330}
331 331
@@ -591,8 +591,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
591 u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk) 591 u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk)
592{ 592{
593 int err, clk; 593 int err, clk;
594 u8 N, min_N, max_N, clk_divider; 594 u8 n, clk_divider, mcu_cnt, div;
595 u8 mcu_cnt, div, max_div;
596 u8 depth[] = { 595 u8 depth[] = {
597 [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M, 596 [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M,
598 [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M, 597 [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M,
@@ -616,10 +615,6 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
616 card_clock /= 1000000; 615 card_clock /= 1000000;
617 dev_dbg(&(pcr->pci->dev), "Switch card clock to %dMHz\n", card_clock); 616 dev_dbg(&(pcr->pci->dev), "Switch card clock to %dMHz\n", card_clock);
618 617
619 min_N = 80;
620 max_N = 208;
621 max_div = CLK_DIV_8;
622
623 clk = card_clock; 618 clk = card_clock;
624 if (!initial_mode && double_clk) 619 if (!initial_mode && double_clk)
625 clk = card_clock * 2; 620 clk = card_clock * 2;
@@ -630,21 +625,31 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
630 if (clk == pcr->cur_clock) 625 if (clk == pcr->cur_clock)
631 return 0; 626 return 0;
632 627
633 N = (u8)(clk - 2); 628 if (pcr->ops->conv_clk_and_div_n)
634 if ((clk <= 2) || (N > max_N)) 629 n = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N);
630 else
631 n = (u8)(clk - 2);
632 if ((clk <= 2) || (n > MAX_DIV_N_PCR))
635 return -EINVAL; 633 return -EINVAL;
636 634
637 mcu_cnt = (u8)(125/clk + 3); 635 mcu_cnt = (u8)(125/clk + 3);
638 if (mcu_cnt > 15) 636 if (mcu_cnt > 15)
639 mcu_cnt = 15; 637 mcu_cnt = 15;
640 638
641 /* Make sure that the SSC clock div_n is equal or greater than min_N */ 639 /* Make sure that the SSC clock div_n is not less than MIN_DIV_N_PCR */
642 div = CLK_DIV_1; 640 div = CLK_DIV_1;
643 while ((N < min_N) && (div < max_div)) { 641 while ((n < MIN_DIV_N_PCR) && (div < CLK_DIV_8)) {
644 N = (N + 2) * 2 - 2; 642 if (pcr->ops->conv_clk_and_div_n) {
643 int dbl_clk = pcr->ops->conv_clk_and_div_n(n,
644 DIV_N_TO_CLK) * 2;
645 n = (u8)pcr->ops->conv_clk_and_div_n(dbl_clk,
646 CLK_TO_DIV_N);
647 } else {
648 n = (n + 2) * 2 - 2;
649 }
645 div++; 650 div++;
646 } 651 }
647 dev_dbg(&(pcr->pci->dev), "N = %d, div = %d\n", N, div); 652 dev_dbg(&(pcr->pci->dev), "n = %d, div = %d\n", n, div);
648 653
649 ssc_depth = depth[ssc_depth]; 654 ssc_depth = depth[ssc_depth];
650 if (double_clk) 655 if (double_clk)
@@ -661,7 +666,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
661 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0); 666 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0);
662 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL2, 667 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL2,
663 SSC_DEPTH_MASK, ssc_depth); 668 SSC_DEPTH_MASK, ssc_depth);
664 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, N); 669 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, n);
665 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, SSC_RSTB); 670 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, SSC_RSTB);
666 if (vpclk) { 671 if (vpclk) {
667 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL, 672 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL,
@@ -703,6 +708,15 @@ int rtsx_pci_card_power_off(struct rtsx_pcr *pcr, int card)
703} 708}
704EXPORT_SYMBOL_GPL(rtsx_pci_card_power_off); 709EXPORT_SYMBOL_GPL(rtsx_pci_card_power_off);
705 710
711int rtsx_pci_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
712{
713 if (pcr->ops->switch_output_voltage)
714 return pcr->ops->switch_output_voltage(pcr, voltage);
715
716 return 0;
717}
718EXPORT_SYMBOL_GPL(rtsx_pci_switch_output_voltage);
719
706unsigned int rtsx_pci_card_exist(struct rtsx_pcr *pcr) 720unsigned int rtsx_pci_card_exist(struct rtsx_pcr *pcr)
707{ 721{
708 unsigned int val; 722 unsigned int val;
@@ -739,7 +753,7 @@ static void rtsx_pci_card_detect(struct work_struct *work)
739 struct delayed_work *dwork; 753 struct delayed_work *dwork;
740 struct rtsx_pcr *pcr; 754 struct rtsx_pcr *pcr;
741 unsigned long flags; 755 unsigned long flags;
742 unsigned int card_detect = 0; 756 unsigned int card_detect = 0, card_inserted, card_removed;
743 u32 irq_status; 757 u32 irq_status;
744 758
745 dwork = to_delayed_work(work); 759 dwork = to_delayed_work(work);
@@ -747,30 +761,37 @@ static void rtsx_pci_card_detect(struct work_struct *work)
747 761
748 dev_dbg(&(pcr->pci->dev), "--> %s\n", __func__); 762 dev_dbg(&(pcr->pci->dev), "--> %s\n", __func__);
749 763
764 mutex_lock(&pcr->pcr_mutex);
750 spin_lock_irqsave(&pcr->lock, flags); 765 spin_lock_irqsave(&pcr->lock, flags);
751 766
752 irq_status = rtsx_pci_readl(pcr, RTSX_BIPR); 767 irq_status = rtsx_pci_readl(pcr, RTSX_BIPR);
753 dev_dbg(&(pcr->pci->dev), "irq_status: 0x%08x\n", irq_status); 768 dev_dbg(&(pcr->pci->dev), "irq_status: 0x%08x\n", irq_status);
754 769
755 if (pcr->card_inserted || pcr->card_removed) { 770 irq_status &= CARD_EXIST;
771 card_inserted = pcr->card_inserted & irq_status;
772 card_removed = pcr->card_removed;
773 pcr->card_inserted = 0;
774 pcr->card_removed = 0;
775
776 spin_unlock_irqrestore(&pcr->lock, flags);
777
778 if (card_inserted || card_removed) {
756 dev_dbg(&(pcr->pci->dev), 779 dev_dbg(&(pcr->pci->dev),
757 "card_inserted: 0x%x, card_removed: 0x%x\n", 780 "card_inserted: 0x%x, card_removed: 0x%x\n",
758 pcr->card_inserted, pcr->card_removed); 781 card_inserted, card_removed);
759 782
760 if (pcr->ops->cd_deglitch) 783 if (pcr->ops->cd_deglitch)
761 pcr->card_inserted = pcr->ops->cd_deglitch(pcr); 784 card_inserted = pcr->ops->cd_deglitch(pcr);
762 785
763 card_detect = pcr->card_inserted | pcr->card_removed; 786 card_detect = card_inserted | card_removed;
764 pcr->card_inserted = 0;
765 pcr->card_removed = 0;
766 } 787 }
767 788
768 spin_unlock_irqrestore(&pcr->lock, flags); 789 mutex_unlock(&pcr->pcr_mutex);
769 790
770 if (card_detect & SD_EXIST) 791 if ((card_detect & SD_EXIST) && pcr->slots[RTSX_SD_CARD].card_event)
771 pcr->slots[RTSX_SD_CARD].card_event( 792 pcr->slots[RTSX_SD_CARD].card_event(
772 pcr->slots[RTSX_SD_CARD].p_dev); 793 pcr->slots[RTSX_SD_CARD].p_dev);
773 if (card_detect & MS_EXIST) 794 if ((card_detect & MS_EXIST) && pcr->slots[RTSX_MS_CARD].card_event)
774 pcr->slots[RTSX_MS_CARD].card_event( 795 pcr->slots[RTSX_MS_CARD].card_event(
775 pcr->slots[RTSX_MS_CARD].p_dev); 796 pcr->slots[RTSX_MS_CARD].p_dev);
776} 797}
@@ -817,10 +838,6 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
817 } 838 }
818 } 839 }
819 840
820 if (pcr->card_inserted || pcr->card_removed)
821 schedule_delayed_work(&pcr->carddet_work,
822 msecs_to_jiffies(200));
823
824 if (int_reg & (NEED_COMPLETE_INT | DELINK_INT)) { 841 if (int_reg & (NEED_COMPLETE_INT | DELINK_INT)) {
825 if (int_reg & (TRANS_FAIL_INT | DELINK_INT)) { 842 if (int_reg & (TRANS_FAIL_INT | DELINK_INT)) {
826 pcr->trans_result = TRANS_RESULT_FAIL; 843 pcr->trans_result = TRANS_RESULT_FAIL;
@@ -833,6 +850,10 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
833 } 850 }
834 } 851 }
835 852
853 if (pcr->card_inserted || pcr->card_removed)
854 schedule_delayed_work(&pcr->carddet_work,
855 msecs_to_jiffies(200));
856
836 spin_unlock(&pcr->lock); 857 spin_unlock(&pcr->lock);
837 return IRQ_HANDLED; 858 return IRQ_HANDLED;
838} 859}
@@ -978,6 +999,10 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
978 case 0x5289: 999 case 0x5289:
979 rtl8411_init_params(pcr); 1000 rtl8411_init_params(pcr);
980 break; 1001 break;
1002
1003 case 0x5227:
1004 rts5227_init_params(pcr);
1005 break;
981 } 1006 }
982 1007
983 dev_dbg(&(pcr->pci->dev), "PID: 0x%04x, IC version: 0x%02x\n", 1008 dev_dbg(&(pcr->pci->dev), "PID: 0x%04x, IC version: 0x%02x\n",
@@ -1011,6 +1036,10 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
1011 pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device, 1036 pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device,
1012 (int)pcidev->revision); 1037 (int)pcidev->revision);
1013 1038
1039 ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(32));
1040 if (ret < 0)
1041 return ret;
1042
1014 ret = pci_enable_device(pcidev); 1043 ret = pci_enable_device(pcidev);
1015 if (ret) 1044 if (ret)
1016 return ret; 1045 return ret;
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
index 12462c1df1a9..2b3ab8a04823 100644
--- a/drivers/mfd/rtsx_pcr.h
+++ b/drivers/mfd/rtsx_pcr.h
@@ -25,8 +25,12 @@
25 25
26#include <linux/mfd/rtsx_pci.h> 26#include <linux/mfd/rtsx_pci.h>
27 27
28#define MIN_DIV_N_PCR 80
29#define MAX_DIV_N_PCR 208
30
28void rts5209_init_params(struct rtsx_pcr *pcr); 31void rts5209_init_params(struct rtsx_pcr *pcr);
29void rts5229_init_params(struct rtsx_pcr *pcr); 32void rts5229_init_params(struct rtsx_pcr *pcr);
30void rtl8411_init_params(struct rtsx_pcr *pcr); 33void rtl8411_init_params(struct rtsx_pcr *pcr);
34void rts5227_init_params(struct rtsx_pcr *pcr);
31 35
32#endif 36#endif
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index a06d66b929b1..ecc092c7f745 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -219,25 +219,18 @@ static void tc3589x_irq_unmap(struct irq_domain *d, unsigned int virq)
219} 219}
220 220
221static struct irq_domain_ops tc3589x_irq_ops = { 221static struct irq_domain_ops tc3589x_irq_ops = {
222 .map = tc3589x_irq_map, 222 .map = tc3589x_irq_map,
223 .unmap = tc3589x_irq_unmap, 223 .unmap = tc3589x_irq_unmap,
224 .xlate = irq_domain_xlate_twocell, 224 .xlate = irq_domain_xlate_twocell,
225}; 225};
226 226
227static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np) 227static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np)
228{ 228{
229 int base = tc3589x->irq_base; 229 int base = tc3589x->irq_base;
230 230
231 if (base) { 231 tc3589x->domain = irq_domain_add_simple(
232 tc3589x->domain = irq_domain_add_legacy( 232 np, TC3589x_NR_INTERNAL_IRQS, base,
233 NULL, TC3589x_NR_INTERNAL_IRQS, base, 233 &tc3589x_irq_ops, tc3589x);
234 0, &tc3589x_irq_ops, tc3589x);
235 }
236 else {
237 tc3589x->domain = irq_domain_add_linear(
238 np, TC3589x_NR_INTERNAL_IRQS,
239 &tc3589x_irq_ops, tc3589x);
240 }
241 234
242 if (!tc3589x->domain) { 235 if (!tc3589x->domain) {
243 dev_err(tc3589x->dev, "Failed to create irqdomain\n"); 236 dev_err(tc3589x->dev, "Failed to create irqdomain\n");
diff --git a/drivers/mfd/tps6507x.c b/drivers/mfd/tps6507x.c
index 409afa23d5dc..5ad4b772b097 100644
--- a/drivers/mfd/tps6507x.c
+++ b/drivers/mfd/tps6507x.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/of_device.h>
22#include <linux/mfd/core.h> 23#include <linux/mfd/core.h>
23#include <linux/mfd/tps6507x.h> 24#include <linux/mfd/tps6507x.h>
24 25
@@ -116,11 +117,19 @@ static const struct i2c_device_id tps6507x_i2c_id[] = {
116}; 117};
117MODULE_DEVICE_TABLE(i2c, tps6507x_i2c_id); 118MODULE_DEVICE_TABLE(i2c, tps6507x_i2c_id);
118 119
120#ifdef CONFIG_OF
121static struct of_device_id tps6507x_of_match[] = {
122 {.compatible = "ti,tps6507x", },
123 {},
124};
125MODULE_DEVICE_TABLE(of, tps6507x_of_match);
126#endif
119 127
120static struct i2c_driver tps6507x_i2c_driver = { 128static struct i2c_driver tps6507x_i2c_driver = {
121 .driver = { 129 .driver = {
122 .name = "tps6507x", 130 .name = "tps6507x",
123 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
132 .of_match_table = of_match_ptr(tps6507x_of_match),
124 }, 133 },
125 .probe = tps6507x_i2c_probe, 134 .probe = tps6507x_i2c_probe,
126 .remove = tps6507x_i2c_remove, 135 .remove = tps6507x_i2c_remove,
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index 8d12a8e00d9c..98edb5be85c6 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -25,6 +25,8 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/mfd/core.h> 26#include <linux/mfd/core.h>
27#include <linux/mfd/tps65090.h> 27#include <linux/mfd/tps65090.h>
28#include <linux/of.h>
29#include <linux/of_device.h>
28#include <linux/err.h> 30#include <linux/err.h>
29 31
30#define NUM_INT_REG 2 32#define NUM_INT_REG 2
@@ -148,18 +150,31 @@ static const struct regmap_config tps65090_regmap_config = {
148 .volatile_reg = is_volatile_reg, 150 .volatile_reg = is_volatile_reg,
149}; 151};
150 152
153#ifdef CONFIG_OF
154static const struct of_device_id tps65090_of_match[] = {
155 { .compatible = "ti,tps65090",},
156 {},
157};
158MODULE_DEVICE_TABLE(of, tps65090_of_match);
159#endif
160
151static int tps65090_i2c_probe(struct i2c_client *client, 161static int tps65090_i2c_probe(struct i2c_client *client,
152 const struct i2c_device_id *id) 162 const struct i2c_device_id *id)
153{ 163{
154 struct tps65090_platform_data *pdata = client->dev.platform_data; 164 struct tps65090_platform_data *pdata = client->dev.platform_data;
165 int irq_base = 0;
155 struct tps65090 *tps65090; 166 struct tps65090 *tps65090;
156 int ret; 167 int ret;
157 168
158 if (!pdata) { 169 if (!pdata && !client->dev.of_node) {
159 dev_err(&client->dev, "tps65090 requires platform data\n"); 170 dev_err(&client->dev,
171 "tps65090 requires platform data or of_node\n");
160 return -EINVAL; 172 return -EINVAL;
161 } 173 }
162 174
175 if (pdata)
176 irq_base = pdata->irq_base;
177
163 tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL); 178 tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL);
164 if (!tps65090) { 179 if (!tps65090) {
165 dev_err(&client->dev, "mem alloc for tps65090 failed\n"); 180 dev_err(&client->dev, "mem alloc for tps65090 failed\n");
@@ -178,7 +193,7 @@ static int tps65090_i2c_probe(struct i2c_client *client,
178 193
179 if (client->irq) { 194 if (client->irq) {
180 ret = regmap_add_irq_chip(tps65090->rmap, client->irq, 195 ret = regmap_add_irq_chip(tps65090->rmap, client->irq,
181 IRQF_ONESHOT | IRQF_TRIGGER_LOW, pdata->irq_base, 196 IRQF_ONESHOT | IRQF_TRIGGER_LOW, irq_base,
182 &tps65090_irq_chip, &tps65090->irq_data); 197 &tps65090_irq_chip, &tps65090->irq_data);
183 if (ret) { 198 if (ret) {
184 dev_err(&client->dev, 199 dev_err(&client->dev,
@@ -189,7 +204,7 @@ static int tps65090_i2c_probe(struct i2c_client *client,
189 204
190 ret = mfd_add_devices(tps65090->dev, -1, tps65090s, 205 ret = mfd_add_devices(tps65090->dev, -1, tps65090s,
191 ARRAY_SIZE(tps65090s), NULL, 206 ARRAY_SIZE(tps65090s), NULL,
192 regmap_irq_chip_get_base(tps65090->irq_data), NULL); 207 0, regmap_irq_get_domain(tps65090->irq_data));
193 if (ret) { 208 if (ret) {
194 dev_err(&client->dev, "add mfd devices failed with err: %d\n", 209 dev_err(&client->dev, "add mfd devices failed with err: %d\n",
195 ret); 210 ret);
@@ -215,28 +230,6 @@ static int tps65090_i2c_remove(struct i2c_client *client)
215 return 0; 230 return 0;
216} 231}
217 232
218#ifdef CONFIG_PM_SLEEP
219static int tps65090_suspend(struct device *dev)
220{
221 struct i2c_client *client = to_i2c_client(dev);
222 if (client->irq)
223 disable_irq(client->irq);
224 return 0;
225}
226
227static int tps65090_resume(struct device *dev)
228{
229 struct i2c_client *client = to_i2c_client(dev);
230 if (client->irq)
231 enable_irq(client->irq);
232 return 0;
233}
234#endif
235
236static const struct dev_pm_ops tps65090_pm_ops = {
237 SET_SYSTEM_SLEEP_PM_OPS(tps65090_suspend, tps65090_resume)
238};
239
240static const struct i2c_device_id tps65090_id_table[] = { 233static const struct i2c_device_id tps65090_id_table[] = {
241 { "tps65090", 0 }, 234 { "tps65090", 0 },
242 { }, 235 { },
@@ -247,7 +240,7 @@ static struct i2c_driver tps65090_driver = {
247 .driver = { 240 .driver = {
248 .name = "tps65090", 241 .name = "tps65090",
249 .owner = THIS_MODULE, 242 .owner = THIS_MODULE,
250 .pm = &tps65090_pm_ops, 243 .of_match_table = of_match_ptr(tps65090_of_match),
251 }, 244 },
252 .probe = tps65090_i2c_probe, 245 .probe = tps65090_i2c_probe,
253 .remove = tps65090_i2c_remove, 246 .remove = tps65090_i2c_remove,
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 4f3baadd0038..557f9ee5ec18 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -66,16 +66,6 @@
66 66
67/* Triton Core internal information (BEGIN) */ 67/* Triton Core internal information (BEGIN) */
68 68
69#define TWL_NUM_SLAVES 4
70
71#define SUB_CHIP_ID0 0
72#define SUB_CHIP_ID1 1
73#define SUB_CHIP_ID2 2
74#define SUB_CHIP_ID3 3
75#define SUB_CHIP_ID_INVAL 0xff
76
77#define TWL_MODULE_LAST TWL4030_MODULE_LAST
78
79/* Base Address defns for twl4030_map[] */ 69/* Base Address defns for twl4030_map[] */
80 70
81/* subchip/slave 0 - USB ID */ 71/* subchip/slave 0 - USB ID */
@@ -94,10 +84,7 @@
94#define TWL4030_BASEADD_MADC 0x0000 84#define TWL4030_BASEADD_MADC 0x0000
95#define TWL4030_BASEADD_MAIN_CHARGE 0x0074 85#define TWL4030_BASEADD_MAIN_CHARGE 0x0074
96#define TWL4030_BASEADD_PRECHARGE 0x00AA 86#define TWL4030_BASEADD_PRECHARGE 0x00AA
97#define TWL4030_BASEADD_PWM0 0x00F8 87#define TWL4030_BASEADD_PWM 0x00F8
98#define TWL4030_BASEADD_PWM1 0x00FB
99#define TWL4030_BASEADD_PWMA 0x00EF
100#define TWL4030_BASEADD_PWMB 0x00F1
101#define TWL4030_BASEADD_KEYPAD 0x00D2 88#define TWL4030_BASEADD_KEYPAD 0x00D2
102 89
103#define TWL5031_BASEADD_ACCESSORY 0x0074 /* Replaces Main Charge */ 90#define TWL5031_BASEADD_ACCESSORY 0x0074 /* Replaces Main Charge */
@@ -117,7 +104,7 @@
117 104
118/* subchip/slave 0 0x48 - POWER */ 105/* subchip/slave 0 0x48 - POWER */
119#define TWL6030_BASEADD_RTC 0x0000 106#define TWL6030_BASEADD_RTC 0x0000
120#define TWL6030_BASEADD_MEM 0x0017 107#define TWL6030_BASEADD_SECURED_REG 0x0017
121#define TWL6030_BASEADD_PM_MASTER 0x001F 108#define TWL6030_BASEADD_PM_MASTER 0x001F
122#define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 /* PM_RECEIVER */ 109#define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 /* PM_RECEIVER */
123#define TWL6030_BASEADD_PM_MISC 0x00E2 110#define TWL6030_BASEADD_PM_MISC 0x00E2
@@ -132,6 +119,7 @@
132#define TWL6030_BASEADD_PIH 0x00D0 119#define TWL6030_BASEADD_PIH 0x00D0
133#define TWL6030_BASEADD_CHARGER 0x00E0 120#define TWL6030_BASEADD_CHARGER 0x00E0
134#define TWL6025_BASEADD_CHARGER 0x00DA 121#define TWL6025_BASEADD_CHARGER 0x00DA
122#define TWL6030_BASEADD_LED 0x00F4
135 123
136/* subchip/slave 2 0x4A - DFT */ 124/* subchip/slave 2 0x4A - DFT */
137#define TWL6030_BASEADD_DIEID 0x00C0 125#define TWL6030_BASEADD_DIEID 0x00C0
@@ -153,33 +141,28 @@
153 141
154/*----------------------------------------------------------------------*/ 142/*----------------------------------------------------------------------*/
155 143
156/* is driver active, bound to a chip? */
157static bool inuse;
158
159/* TWL IDCODE Register value */
160static u32 twl_idcode;
161
162static unsigned int twl_id;
163unsigned int twl_rev(void)
164{
165 return twl_id;
166}
167EXPORT_SYMBOL(twl_rev);
168
169/* Structure for each TWL4030/TWL6030 Slave */ 144/* Structure for each TWL4030/TWL6030 Slave */
170struct twl_client { 145struct twl_client {
171 struct i2c_client *client; 146 struct i2c_client *client;
172 struct regmap *regmap; 147 struct regmap *regmap;
173}; 148};
174 149
175static struct twl_client twl_modules[TWL_NUM_SLAVES];
176
177/* mapping the module id to slave id and base address */ 150/* mapping the module id to slave id and base address */
178struct twl_mapping { 151struct twl_mapping {
179 unsigned char sid; /* Slave ID */ 152 unsigned char sid; /* Slave ID */
180 unsigned char base; /* base address */ 153 unsigned char base; /* base address */
181}; 154};
182static struct twl_mapping *twl_map; 155
156struct twl_private {
157 bool ready; /* The core driver is ready to be used */
158 u32 twl_idcode; /* TWL IDCODE Register value */
159 unsigned int twl_id;
160
161 struct twl_mapping *twl_map;
162 struct twl_client *twl_modules;
163};
164
165static struct twl_private *twl_priv;
183 166
184static struct twl_mapping twl4030_map[] = { 167static struct twl_mapping twl4030_map[] = {
185 /* 168 /*
@@ -188,34 +171,33 @@ static struct twl_mapping twl4030_map[] = {
188 * so they continue to match the order in this table. 171 * so they continue to match the order in this table.
189 */ 172 */
190 173
174 /* Common IPs */
191 { 0, TWL4030_BASEADD_USB }, 175 { 0, TWL4030_BASEADD_USB },
176 { 1, TWL4030_BASEADD_PIH },
177 { 2, TWL4030_BASEADD_MAIN_CHARGE },
178 { 3, TWL4030_BASEADD_PM_MASTER },
179 { 3, TWL4030_BASEADD_PM_RECEIVER },
180
181 { 3, TWL4030_BASEADD_RTC },
182 { 2, TWL4030_BASEADD_PWM },
183 { 2, TWL4030_BASEADD_LED },
184 { 3, TWL4030_BASEADD_SECURED_REG },
185
186 /* TWL4030 specific IPs */
192 { 1, TWL4030_BASEADD_AUDIO_VOICE }, 187 { 1, TWL4030_BASEADD_AUDIO_VOICE },
193 { 1, TWL4030_BASEADD_GPIO }, 188 { 1, TWL4030_BASEADD_GPIO },
194 { 1, TWL4030_BASEADD_INTBR }, 189 { 1, TWL4030_BASEADD_INTBR },
195 { 1, TWL4030_BASEADD_PIH },
196
197 { 1, TWL4030_BASEADD_TEST }, 190 { 1, TWL4030_BASEADD_TEST },
198 { 2, TWL4030_BASEADD_KEYPAD }, 191 { 2, TWL4030_BASEADD_KEYPAD },
192
199 { 2, TWL4030_BASEADD_MADC }, 193 { 2, TWL4030_BASEADD_MADC },
200 { 2, TWL4030_BASEADD_INTERRUPTS }, 194 { 2, TWL4030_BASEADD_INTERRUPTS },
201 { 2, TWL4030_BASEADD_LED },
202
203 { 2, TWL4030_BASEADD_MAIN_CHARGE },
204 { 2, TWL4030_BASEADD_PRECHARGE }, 195 { 2, TWL4030_BASEADD_PRECHARGE },
205 { 2, TWL4030_BASEADD_PWM0 },
206 { 2, TWL4030_BASEADD_PWM1 },
207 { 2, TWL4030_BASEADD_PWMA },
208
209 { 2, TWL4030_BASEADD_PWMB },
210 { 2, TWL5031_BASEADD_ACCESSORY },
211 { 2, TWL5031_BASEADD_INTERRUPTS },
212 { 3, TWL4030_BASEADD_BACKUP }, 196 { 3, TWL4030_BASEADD_BACKUP },
213 { 3, TWL4030_BASEADD_INT }, 197 { 3, TWL4030_BASEADD_INT },
214 198
215 { 3, TWL4030_BASEADD_PM_MASTER }, 199 { 2, TWL5031_BASEADD_ACCESSORY },
216 { 3, TWL4030_BASEADD_PM_RECEIVER }, 200 { 2, TWL5031_BASEADD_INTERRUPTS },
217 { 3, TWL4030_BASEADD_RTC },
218 { 3, TWL4030_BASEADD_SECURED_REG },
219}; 201};
220 202
221static struct regmap_config twl4030_regmap_config[4] = { 203static struct regmap_config twl4030_regmap_config[4] = {
@@ -251,35 +233,25 @@ static struct twl_mapping twl6030_map[] = {
251 * <linux/i2c/twl.h> defines for TWL4030_MODULE_* 233 * <linux/i2c/twl.h> defines for TWL4030_MODULE_*
252 * so they continue to match the order in this table. 234 * so they continue to match the order in this table.
253 */ 235 */
254 { SUB_CHIP_ID1, TWL6030_BASEADD_USB }, 236
255 { SUB_CHIP_ID_INVAL, TWL6030_BASEADD_AUDIO }, 237 /* Common IPs */
256 { SUB_CHIP_ID2, TWL6030_BASEADD_DIEID }, 238 { 1, TWL6030_BASEADD_USB },
257 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 239 { 1, TWL6030_BASEADD_PIH },
258 { SUB_CHIP_ID1, TWL6030_BASEADD_PIH }, 240 { 1, TWL6030_BASEADD_CHARGER },
259 241 { 0, TWL6030_BASEADD_PM_MASTER },
260 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 242 { 0, TWL6030_BASEADD_PM_SLAVE_MISC },
261 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 243
262 { SUB_CHIP_ID1, TWL6030_BASEADD_GPADC_CTRL }, 244 { 0, TWL6030_BASEADD_RTC },
263 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 245 { 1, TWL6030_BASEADD_PWM },
264 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 246 { 1, TWL6030_BASEADD_LED },
265 247 { 0, TWL6030_BASEADD_SECURED_REG },
266 { SUB_CHIP_ID1, TWL6030_BASEADD_CHARGER }, 248
267 { SUB_CHIP_ID1, TWL6030_BASEADD_GASGAUGE }, 249 /* TWL6030 specific IPs */
268 { SUB_CHIP_ID1, TWL6030_BASEADD_PWM }, 250 { 0, TWL6030_BASEADD_ZERO },
269 { SUB_CHIP_ID0, TWL6030_BASEADD_ZERO }, 251 { 1, TWL6030_BASEADD_ZERO },
270 { SUB_CHIP_ID1, TWL6030_BASEADD_ZERO }, 252 { 2, TWL6030_BASEADD_ZERO },
271 253 { 1, TWL6030_BASEADD_GPADC_CTRL },
272 { SUB_CHIP_ID2, TWL6030_BASEADD_ZERO }, 254 { 1, TWL6030_BASEADD_GASGAUGE },
273 { SUB_CHIP_ID2, TWL6030_BASEADD_ZERO },
274 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
275 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
276 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
277
278 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER },
279 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC },
280 { SUB_CHIP_ID0, TWL6030_BASEADD_RTC },
281 { SUB_CHIP_ID0, TWL6030_BASEADD_MEM },
282 { SUB_CHIP_ID1, TWL6025_BASEADD_CHARGER },
283}; 255};
284 256
285static struct regmap_config twl6030_regmap_config[3] = { 257static struct regmap_config twl6030_regmap_config[3] = {
@@ -305,8 +277,30 @@ static struct regmap_config twl6030_regmap_config[3] = {
305 277
306/*----------------------------------------------------------------------*/ 278/*----------------------------------------------------------------------*/
307 279
280static inline int twl_get_num_slaves(void)
281{
282 if (twl_class_is_4030())
283 return 4; /* TWL4030 class have four slave address */
284 else
285 return 3; /* TWL6030 class have three slave address */
286}
287
288static inline int twl_get_last_module(void)
289{
290 if (twl_class_is_4030())
291 return TWL4030_MODULE_LAST;
292 else
293 return TWL6030_MODULE_LAST;
294}
295
308/* Exported Functions */ 296/* Exported Functions */
309 297
298unsigned int twl_rev(void)
299{
300 return twl_priv ? twl_priv->twl_id : 0;
301}
302EXPORT_SYMBOL(twl_rev);
303
310/** 304/**
311 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0 305 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
312 * @mod_no: module number 306 * @mod_no: module number
@@ -314,9 +308,6 @@ static struct regmap_config twl6030_regmap_config[3] = {
314 * @reg: register address (just offset will do) 308 * @reg: register address (just offset will do)
315 * @num_bytes: number of bytes to transfer 309 * @num_bytes: number of bytes to transfer
316 * 310 *
317 * IMPORTANT: for 'value' parameter: Allocate value num_bytes+1 and
318 * valid data starts at Offset 1.
319 *
320 * Returns the result of operation - 0 is success 311 * Returns the result of operation - 0 is success
321 */ 312 */
322int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 313int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
@@ -325,24 +316,21 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
325 int sid; 316 int sid;
326 struct twl_client *twl; 317 struct twl_client *twl;
327 318
328 if (unlikely(mod_no >= TWL_MODULE_LAST)) { 319 if (unlikely(mod_no >= twl_get_last_module())) {
329 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 320 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
330 return -EPERM; 321 return -EPERM;
331 } 322 }
332 if (unlikely(!inuse)) { 323 if (unlikely(!twl_priv->ready)) {
333 pr_err("%s: not initialized\n", DRIVER_NAME); 324 pr_err("%s: not initialized\n", DRIVER_NAME);
334 return -EPERM; 325 return -EPERM;
335 } 326 }
336 sid = twl_map[mod_no].sid;
337 if (unlikely(sid == SUB_CHIP_ID_INVAL)) {
338 pr_err("%s: module %d is not part of the pmic\n",
339 DRIVER_NAME, mod_no);
340 return -EINVAL;
341 }
342 twl = &twl_modules[sid];
343 327
344 ret = regmap_bulk_write(twl->regmap, twl_map[mod_no].base + reg, 328 sid = twl_priv->twl_map[mod_no].sid;
345 value, num_bytes); 329 twl = &twl_priv->twl_modules[sid];
330
331 ret = regmap_bulk_write(twl->regmap,
332 twl_priv->twl_map[mod_no].base + reg, value,
333 num_bytes);
346 334
347 if (ret) 335 if (ret)
348 pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n", 336 pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n",
@@ -367,24 +355,21 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
367 int sid; 355 int sid;
368 struct twl_client *twl; 356 struct twl_client *twl;
369 357
370 if (unlikely(mod_no >= TWL_MODULE_LAST)) { 358 if (unlikely(mod_no >= twl_get_last_module())) {
371 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 359 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
372 return -EPERM; 360 return -EPERM;
373 } 361 }
374 if (unlikely(!inuse)) { 362 if (unlikely(!twl_priv->ready)) {
375 pr_err("%s: not initialized\n", DRIVER_NAME); 363 pr_err("%s: not initialized\n", DRIVER_NAME);
376 return -EPERM; 364 return -EPERM;
377 } 365 }
378 sid = twl_map[mod_no].sid;
379 if (unlikely(sid == SUB_CHIP_ID_INVAL)) {
380 pr_err("%s: module %d is not part of the pmic\n",
381 DRIVER_NAME, mod_no);
382 return -EINVAL;
383 }
384 twl = &twl_modules[sid];
385 366
386 ret = regmap_bulk_read(twl->regmap, twl_map[mod_no].base + reg, 367 sid = twl_priv->twl_map[mod_no].sid;
387 value, num_bytes); 368 twl = &twl_priv->twl_modules[sid];
369
370 ret = regmap_bulk_read(twl->regmap,
371 twl_priv->twl_map[mod_no].base + reg, value,
372 num_bytes);
388 373
389 if (ret) 374 if (ret)
390 pr_err("%s: Read failed (mod %d, reg 0x%02x count %d)\n", 375 pr_err("%s: Read failed (mod %d, reg 0x%02x count %d)\n",
@@ -394,34 +379,6 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
394} 379}
395EXPORT_SYMBOL(twl_i2c_read); 380EXPORT_SYMBOL(twl_i2c_read);
396 381
397/**
398 * twl_i2c_write_u8 - Writes a 8 bit register in TWL4030/TWL5030/TWL60X0
399 * @mod_no: module number
400 * @value: the value to be written 8 bit
401 * @reg: register address (just offset will do)
402 *
403 * Returns result of operation - 0 is success
404 */
405int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
406{
407 return twl_i2c_write(mod_no, &value, reg, 1);
408}
409EXPORT_SYMBOL(twl_i2c_write_u8);
410
411/**
412 * twl_i2c_read_u8 - Reads a 8 bit register from TWL4030/TWL5030/TWL60X0
413 * @mod_no: module number
414 * @value: the value read 8 bit
415 * @reg: register address (just offset will do)
416 *
417 * Returns result of operation - 0 is success
418 */
419int twl_i2c_read_u8(u8 mod_no, u8 *value, u8 reg)
420{
421 return twl_i2c_read(mod_no, value, reg, 1);
422}
423EXPORT_SYMBOL(twl_i2c_read_u8);
424
425/*----------------------------------------------------------------------*/ 382/*----------------------------------------------------------------------*/
426 383
427/** 384/**
@@ -440,7 +397,7 @@ static int twl_read_idcode_register(void)
440 goto fail; 397 goto fail;
441 } 398 }
442 399
443 err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_idcode), 400 err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_priv->twl_idcode),
444 REG_IDCODE_7_0, 4); 401 REG_IDCODE_7_0, 4);
445 if (err) { 402 if (err) {
446 pr_err("TWL4030: unable to read IDCODE -%d\n", err); 403 pr_err("TWL4030: unable to read IDCODE -%d\n", err);
@@ -461,7 +418,7 @@ fail:
461 */ 418 */
462int twl_get_type(void) 419int twl_get_type(void)
463{ 420{
464 return TWL_SIL_TYPE(twl_idcode); 421 return TWL_SIL_TYPE(twl_priv->twl_idcode);
465} 422}
466EXPORT_SYMBOL_GPL(twl_get_type); 423EXPORT_SYMBOL_GPL(twl_get_type);
467 424
@@ -472,7 +429,7 @@ EXPORT_SYMBOL_GPL(twl_get_type);
472 */ 429 */
473int twl_get_version(void) 430int twl_get_version(void)
474{ 431{
475 return TWL_SIL_REV(twl_idcode); 432 return TWL_SIL_REV(twl_priv->twl_idcode);
476} 433}
477EXPORT_SYMBOL_GPL(twl_get_version); 434EXPORT_SYMBOL_GPL(twl_get_version);
478 435
@@ -509,13 +466,20 @@ int twl_get_hfclk_rate(void)
509EXPORT_SYMBOL_GPL(twl_get_hfclk_rate); 466EXPORT_SYMBOL_GPL(twl_get_hfclk_rate);
510 467
511static struct device * 468static struct device *
512add_numbered_child(unsigned chip, const char *name, int num, 469add_numbered_child(unsigned mod_no, const char *name, int num,
513 void *pdata, unsigned pdata_len, 470 void *pdata, unsigned pdata_len,
514 bool can_wakeup, int irq0, int irq1) 471 bool can_wakeup, int irq0, int irq1)
515{ 472{
516 struct platform_device *pdev; 473 struct platform_device *pdev;
517 struct twl_client *twl = &twl_modules[chip]; 474 struct twl_client *twl;
518 int status; 475 int status, sid;
476
477 if (unlikely(mod_no >= twl_get_last_module())) {
478 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
479 return ERR_PTR(-EPERM);
480 }
481 sid = twl_priv->twl_map[mod_no].sid;
482 twl = &twl_priv->twl_modules[sid];
519 483
520 pdev = platform_device_alloc(name, num); 484 pdev = platform_device_alloc(name, num);
521 if (!pdev) { 485 if (!pdev) {
@@ -560,11 +524,11 @@ err:
560 return &pdev->dev; 524 return &pdev->dev;
561} 525}
562 526
563static inline struct device *add_child(unsigned chip, const char *name, 527static inline struct device *add_child(unsigned mod_no, const char *name,
564 void *pdata, unsigned pdata_len, 528 void *pdata, unsigned pdata_len,
565 bool can_wakeup, int irq0, int irq1) 529 bool can_wakeup, int irq0, int irq1)
566{ 530{
567 return add_numbered_child(chip, name, -1, pdata, pdata_len, 531 return add_numbered_child(mod_no, name, -1, pdata, pdata_len,
568 can_wakeup, irq0, irq1); 532 can_wakeup, irq0, irq1);
569} 533}
570 534
@@ -573,7 +537,6 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
573 struct regulator_consumer_supply *consumers, 537 struct regulator_consumer_supply *consumers,
574 unsigned num_consumers, unsigned long features) 538 unsigned num_consumers, unsigned long features)
575{ 539{
576 unsigned sub_chip_id;
577 struct twl_regulator_driver_data drv_data; 540 struct twl_regulator_driver_data drv_data;
578 541
579 /* regulator framework demands init_data ... */ 542 /* regulator framework demands init_data ... */
@@ -600,8 +563,7 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
600 } 563 }
601 564
602 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */ 565 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */
603 sub_chip_id = twl_map[TWL_MODULE_PM_MASTER].sid; 566 return add_numbered_child(TWL_MODULE_PM_MASTER, "twl_reg", num,
604 return add_numbered_child(sub_chip_id, "twl_reg", num,
605 pdata, sizeof(*pdata), false, 0, 0); 567 pdata, sizeof(*pdata), false, 0, 0);
606} 568}
607 569
@@ -623,10 +585,9 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
623 unsigned long features) 585 unsigned long features)
624{ 586{
625 struct device *child; 587 struct device *child;
626 unsigned sub_chip_id;
627 588
628 if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) { 589 if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) {
629 child = add_child(SUB_CHIP_ID1, "twl4030_gpio", 590 child = add_child(TWL4030_MODULE_GPIO, "twl4030_gpio",
630 pdata->gpio, sizeof(*pdata->gpio), 591 pdata->gpio, sizeof(*pdata->gpio),
631 false, irq_base + GPIO_INTR_OFFSET, 0); 592 false, irq_base + GPIO_INTR_OFFSET, 0);
632 if (IS_ERR(child)) 593 if (IS_ERR(child))
@@ -634,7 +595,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
634 } 595 }
635 596
636 if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) { 597 if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) {
637 child = add_child(SUB_CHIP_ID2, "twl4030_keypad", 598 child = add_child(TWL4030_MODULE_KEYPAD, "twl4030_keypad",
638 pdata->keypad, sizeof(*pdata->keypad), 599 pdata->keypad, sizeof(*pdata->keypad),
639 true, irq_base + KEYPAD_INTR_OFFSET, 0); 600 true, irq_base + KEYPAD_INTR_OFFSET, 0);
640 if (IS_ERR(child)) 601 if (IS_ERR(child))
@@ -643,7 +604,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
643 604
644 if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc && 605 if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc &&
645 twl_class_is_4030()) { 606 twl_class_is_4030()) {
646 child = add_child(SUB_CHIP_ID2, "twl4030_madc", 607 child = add_child(TWL4030_MODULE_MADC, "twl4030_madc",
647 pdata->madc, sizeof(*pdata->madc), 608 pdata->madc, sizeof(*pdata->madc),
648 true, irq_base + MADC_INTR_OFFSET, 0); 609 true, irq_base + MADC_INTR_OFFSET, 0);
649 if (IS_ERR(child)) 610 if (IS_ERR(child))
@@ -658,22 +619,21 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
658 * Eventually, Linux might become more aware of such 619 * Eventually, Linux might become more aware of such
659 * HW security concerns, and "least privilege". 620 * HW security concerns, and "least privilege".
660 */ 621 */
661 sub_chip_id = twl_map[TWL_MODULE_RTC].sid; 622 child = add_child(TWL_MODULE_RTC, "twl_rtc", NULL, 0,
662 child = add_child(sub_chip_id, "twl_rtc", NULL, 0,
663 true, irq_base + RTC_INTR_OFFSET, 0); 623 true, irq_base + RTC_INTR_OFFSET, 0);
664 if (IS_ERR(child)) 624 if (IS_ERR(child))
665 return PTR_ERR(child); 625 return PTR_ERR(child);
666 } 626 }
667 627
668 if (IS_ENABLED(CONFIG_PWM_TWL)) { 628 if (IS_ENABLED(CONFIG_PWM_TWL)) {
669 child = add_child(SUB_CHIP_ID1, "twl-pwm", NULL, 0, 629 child = add_child(TWL_MODULE_PWM, "twl-pwm", NULL, 0,
670 false, 0, 0); 630 false, 0, 0);
671 if (IS_ERR(child)) 631 if (IS_ERR(child))
672 return PTR_ERR(child); 632 return PTR_ERR(child);
673 } 633 }
674 634
675 if (IS_ENABLED(CONFIG_PWM_TWL_LED)) { 635 if (IS_ENABLED(CONFIG_PWM_TWL_LED)) {
676 child = add_child(SUB_CHIP_ID1, "twl-pwmled", NULL, 0, 636 child = add_child(TWL_MODULE_LED, "twl-pwmled", NULL, 0,
677 false, 0, 0); 637 false, 0, 0);
678 if (IS_ERR(child)) 638 if (IS_ERR(child))
679 return PTR_ERR(child); 639 return PTR_ERR(child);
@@ -725,7 +685,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
725 685
726 } 686 }
727 687
728 child = add_child(SUB_CHIP_ID0, "twl4030_usb", 688 child = add_child(TWL_MODULE_USB, "twl4030_usb",
729 pdata->usb, sizeof(*pdata->usb), true, 689 pdata->usb, sizeof(*pdata->usb), true,
730 /* irq0 = USB_PRES, irq1 = USB */ 690 /* irq0 = USB_PRES, irq1 = USB */
731 irq_base + USB_PRES_INTR_OFFSET, 691 irq_base + USB_PRES_INTR_OFFSET,
@@ -774,7 +734,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
774 734
775 pdata->usb->features = features; 735 pdata->usb->features = features;
776 736
777 child = add_child(SUB_CHIP_ID0, "twl6030_usb", 737 child = add_child(TWL_MODULE_USB, "twl6030_usb",
778 pdata->usb, sizeof(*pdata->usb), true, 738 pdata->usb, sizeof(*pdata->usb), true,
779 /* irq1 = VBUS_PRES, irq0 = USB ID */ 739 /* irq1 = VBUS_PRES, irq0 = USB ID */
780 irq_base + USBOTG_INTR_OFFSET, 740 irq_base + USBOTG_INTR_OFFSET,
@@ -799,22 +759,22 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
799 } 759 }
800 760
801 if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { 761 if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) {
802 child = add_child(SUB_CHIP_ID3, "twl4030_wdt", NULL, 0, 762 child = add_child(TWL_MODULE_PM_RECEIVER, "twl4030_wdt", NULL,
803 false, 0, 0); 763 0, false, 0, 0);
804 if (IS_ERR(child)) 764 if (IS_ERR(child))
805 return PTR_ERR(child); 765 return PTR_ERR(child);
806 } 766 }
807 767
808 if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) { 768 if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) {
809 child = add_child(SUB_CHIP_ID3, "twl4030_pwrbutton", NULL, 0, 769 child = add_child(TWL_MODULE_PM_MASTER, "twl4030_pwrbutton",
810 true, irq_base + 8 + 0, 0); 770 NULL, 0, true, irq_base + 8 + 0, 0);
811 if (IS_ERR(child)) 771 if (IS_ERR(child))
812 return PTR_ERR(child); 772 return PTR_ERR(child);
813 } 773 }
814 774
815 if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio && 775 if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio &&
816 twl_class_is_4030()) { 776 twl_class_is_4030()) {
817 child = add_child(SUB_CHIP_ID1, "twl4030-audio", 777 child = add_child(TWL4030_MODULE_AUDIO_VOICE, "twl4030-audio",
818 pdata->audio, sizeof(*pdata->audio), 778 pdata->audio, sizeof(*pdata->audio),
819 false, 0, 0); 779 false, 0, 0);
820 if (IS_ERR(child)) 780 if (IS_ERR(child))
@@ -1054,7 +1014,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
1054 1014
1055 if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && 1015 if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci &&
1056 !(features & (TPS_SUBSET | TWL5031))) { 1016 !(features & (TPS_SUBSET | TWL5031))) {
1057 child = add_child(SUB_CHIP_ID3, "twl4030_bci", 1017 child = add_child(TWL_MODULE_MAIN_CHARGE, "twl4030_bci",
1058 pdata->bci, sizeof(*pdata->bci), false, 1018 pdata->bci, sizeof(*pdata->bci), false,
1059 /* irq0 = CHG_PRES, irq1 = BCI */ 1019 /* irq0 = CHG_PRES, irq1 = BCI */
1060 irq_base + BCI_PRES_INTR_OFFSET, 1020 irq_base + BCI_PRES_INTR_OFFSET,
@@ -1145,25 +1105,23 @@ static int twl_remove(struct i2c_client *client)
1145 unsigned i, num_slaves; 1105 unsigned i, num_slaves;
1146 int status; 1106 int status;
1147 1107
1148 if (twl_class_is_4030()) { 1108 if (twl_class_is_4030())
1149 status = twl4030_exit_irq(); 1109 status = twl4030_exit_irq();
1150 num_slaves = TWL_NUM_SLAVES; 1110 else
1151 } else {
1152 status = twl6030_exit_irq(); 1111 status = twl6030_exit_irq();
1153 num_slaves = TWL_NUM_SLAVES - 1;
1154 }
1155 1112
1156 if (status < 0) 1113 if (status < 0)
1157 return status; 1114 return status;
1158 1115
1116 num_slaves = twl_get_num_slaves();
1159 for (i = 0; i < num_slaves; i++) { 1117 for (i = 0; i < num_slaves; i++) {
1160 struct twl_client *twl = &twl_modules[i]; 1118 struct twl_client *twl = &twl_priv->twl_modules[i];
1161 1119
1162 if (twl->client && twl->client != client) 1120 if (twl->client && twl->client != client)
1163 i2c_unregister_device(twl->client); 1121 i2c_unregister_device(twl->client);
1164 twl_modules[i].client = NULL; 1122 twl->client = NULL;
1165 } 1123 }
1166 inuse = false; 1124 twl_priv->ready = false;
1167 return 0; 1125 return 0;
1168} 1126}
1169 1127
@@ -1179,6 +1137,17 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1179 int status; 1137 int status;
1180 unsigned i, num_slaves; 1138 unsigned i, num_slaves;
1181 1139
1140 if (!node && !pdata) {
1141 dev_err(&client->dev, "no platform data\n");
1142 return -EINVAL;
1143 }
1144
1145 if (twl_priv) {
1146 dev_dbg(&client->dev, "only one instance of %s allowed\n",
1147 DRIVER_NAME);
1148 return -EBUSY;
1149 }
1150
1182 pdev = platform_device_alloc(DRIVER_NAME, -1); 1151 pdev = platform_device_alloc(DRIVER_NAME, -1);
1183 if (!pdev) { 1152 if (!pdev) {
1184 dev_err(&client->dev, "can't alloc pdev\n"); 1153 dev_err(&client->dev, "can't alloc pdev\n");
@@ -1191,54 +1160,44 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1191 return status; 1160 return status;
1192 } 1161 }
1193 1162
1194 if (node && !pdata) {
1195 /*
1196 * XXX: Temporary pdata until the information is correctly
1197 * retrieved by every TWL modules from DT.
1198 */
1199 pdata = devm_kzalloc(&client->dev,
1200 sizeof(struct twl4030_platform_data),
1201 GFP_KERNEL);
1202 if (!pdata) {
1203 status = -ENOMEM;
1204 goto free;
1205 }
1206 }
1207
1208 if (!pdata) {
1209 dev_dbg(&client->dev, "no platform data?\n");
1210 status = -EINVAL;
1211 goto free;
1212 }
1213
1214 platform_set_drvdata(pdev, pdata);
1215
1216 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { 1163 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
1217 dev_dbg(&client->dev, "can't talk I2C?\n"); 1164 dev_dbg(&client->dev, "can't talk I2C?\n");
1218 status = -EIO; 1165 status = -EIO;
1219 goto free; 1166 goto free;
1220 } 1167 }
1221 1168
1222 if (inuse) { 1169 twl_priv = devm_kzalloc(&client->dev, sizeof(struct twl_private),
1223 dev_dbg(&client->dev, "driver is already in use\n"); 1170 GFP_KERNEL);
1224 status = -EBUSY; 1171 if (!twl_priv) {
1172 status = -ENOMEM;
1225 goto free; 1173 goto free;
1226 } 1174 }
1227 1175
1228 if ((id->driver_data) & TWL6030_CLASS) { 1176 if ((id->driver_data) & TWL6030_CLASS) {
1229 twl_id = TWL6030_CLASS_ID; 1177 twl_priv->twl_id = TWL6030_CLASS_ID;
1230 twl_map = &twl6030_map[0]; 1178 twl_priv->twl_map = &twl6030_map[0];
1179 /* The charger base address is different in twl6025 */
1180 if ((id->driver_data) & TWL6025_SUBCLASS)
1181 twl_priv->twl_map[TWL_MODULE_MAIN_CHARGE].base =
1182 TWL6025_BASEADD_CHARGER;
1231 twl_regmap_config = twl6030_regmap_config; 1183 twl_regmap_config = twl6030_regmap_config;
1232 num_slaves = TWL_NUM_SLAVES - 1;
1233 } else { 1184 } else {
1234 twl_id = TWL4030_CLASS_ID; 1185 twl_priv->twl_id = TWL4030_CLASS_ID;
1235 twl_map = &twl4030_map[0]; 1186 twl_priv->twl_map = &twl4030_map[0];
1236 twl_regmap_config = twl4030_regmap_config; 1187 twl_regmap_config = twl4030_regmap_config;
1237 num_slaves = TWL_NUM_SLAVES; 1188 }
1189
1190 num_slaves = twl_get_num_slaves();
1191 twl_priv->twl_modules = devm_kzalloc(&client->dev,
1192 sizeof(struct twl_client) * num_slaves,
1193 GFP_KERNEL);
1194 if (!twl_priv->twl_modules) {
1195 status = -ENOMEM;
1196 goto free;
1238 } 1197 }
1239 1198
1240 for (i = 0; i < num_slaves; i++) { 1199 for (i = 0; i < num_slaves; i++) {
1241 struct twl_client *twl = &twl_modules[i]; 1200 struct twl_client *twl = &twl_priv->twl_modules[i];
1242 1201
1243 if (i == 0) { 1202 if (i == 0) {
1244 twl->client = client; 1203 twl->client = client;
@@ -1264,19 +1223,19 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1264 } 1223 }
1265 } 1224 }
1266 1225
1267 inuse = true; 1226 twl_priv->ready = true;
1268 1227
1269 /* setup clock framework */ 1228 /* setup clock framework */
1270 clocks_init(&pdev->dev, pdata->clock); 1229 clocks_init(&pdev->dev, pdata ? pdata->clock : NULL);
1271 1230
1272 /* read TWL IDCODE Register */ 1231 /* read TWL IDCODE Register */
1273 if (twl_id == TWL4030_CLASS_ID) { 1232 if (twl_class_is_4030()) {
1274 status = twl_read_idcode_register(); 1233 status = twl_read_idcode_register();
1275 WARN(status < 0, "Error: reading twl_idcode register value\n"); 1234 WARN(status < 0, "Error: reading twl_idcode register value\n");
1276 } 1235 }
1277 1236
1278 /* load power event scripts */ 1237 /* load power event scripts */
1279 if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata->power) 1238 if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata && pdata->power)
1280 twl4030_power_init(pdata->power); 1239 twl4030_power_init(pdata->power);
1281 1240
1282 /* Maybe init the T2 Interrupt subsystem */ 1241 /* Maybe init the T2 Interrupt subsystem */
@@ -1308,10 +1267,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1308 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); 1267 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
1309 } 1268 }
1310 1269
1311 status = -ENODEV;
1312 if (node) 1270 if (node)
1313 status = of_platform_populate(node, NULL, NULL, &client->dev); 1271 status = of_platform_populate(node, NULL, NULL, &client->dev);
1314 if (status) 1272 else
1315 status = add_children(pdata, irq_base, id->driver_data); 1273 status = add_children(pdata, irq_base, id->driver_data);
1316 1274
1317fail: 1275fail:
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 4dae241e5017..dd362c1078e1 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -159,7 +159,7 @@ out:
159static int twl4030_write_script(u8 address, struct twl4030_ins *script, 159static int twl4030_write_script(u8 address, struct twl4030_ins *script,
160 int len) 160 int len)
161{ 161{
162 int err; 162 int err = -EINVAL;
163 163
164 for (; len; len--, address++, script++) { 164 for (; len; len--, address++, script++) {
165 if (len == 1) { 165 if (len == 1) {
diff --git a/drivers/mfd/vexpress-config.c b/drivers/mfd/vexpress-config.c
index fae15d880758..3c1723aa6225 100644
--- a/drivers/mfd/vexpress-config.c
+++ b/drivers/mfd/vexpress-config.c
@@ -67,6 +67,7 @@ struct vexpress_config_bridge *vexpress_config_bridge_register(
67 67
68 return bridge; 68 return bridge;
69} 69}
70EXPORT_SYMBOL(vexpress_config_bridge_register);
70 71
71void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge) 72void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge)
72{ 73{
@@ -83,6 +84,7 @@ void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge)
83 while (!list_empty(&__bridge.transactions)) 84 while (!list_empty(&__bridge.transactions))
84 cpu_relax(); 85 cpu_relax();
85} 86}
87EXPORT_SYMBOL(vexpress_config_bridge_unregister);
86 88
87 89
88struct vexpress_config_func { 90struct vexpress_config_func {
@@ -142,6 +144,7 @@ struct vexpress_config_func *__vexpress_config_func_get(struct device *dev,
142 144
143 return func; 145 return func;
144} 146}
147EXPORT_SYMBOL(__vexpress_config_func_get);
145 148
146void vexpress_config_func_put(struct vexpress_config_func *func) 149void vexpress_config_func_put(struct vexpress_config_func *func)
147{ 150{
@@ -149,7 +152,7 @@ void vexpress_config_func_put(struct vexpress_config_func *func)
149 of_node_put(func->bridge->node); 152 of_node_put(func->bridge->node);
150 kfree(func); 153 kfree(func);
151} 154}
152 155EXPORT_SYMBOL(vexpress_config_func_put);
153 156
154struct vexpress_config_trans { 157struct vexpress_config_trans {
155 struct vexpress_config_func *func; 158 struct vexpress_config_func *func;
@@ -229,6 +232,7 @@ void vexpress_config_complete(struct vexpress_config_bridge *bridge,
229 232
230 complete(&trans->completion); 233 complete(&trans->completion);
231} 234}
235EXPORT_SYMBOL(vexpress_config_complete);
232 236
233int vexpress_config_wait(struct vexpress_config_trans *trans) 237int vexpress_config_wait(struct vexpress_config_trans *trans)
234{ 238{
@@ -236,7 +240,7 @@ int vexpress_config_wait(struct vexpress_config_trans *trans)
236 240
237 return trans->status; 241 return trans->status;
238} 242}
239 243EXPORT_SYMBOL(vexpress_config_wait);
240 244
241int vexpress_config_read(struct vexpress_config_func *func, int offset, 245int vexpress_config_read(struct vexpress_config_func *func, int offset,
242 u32 *data) 246 u32 *data)
diff --git a/drivers/mfd/vexpress-sysreg.c b/drivers/mfd/vexpress-sysreg.c
index 77048b18439e..a4a43230abcd 100644
--- a/drivers/mfd/vexpress-sysreg.c
+++ b/drivers/mfd/vexpress-sysreg.c
@@ -49,6 +49,8 @@
49#define SYS_ID_HBI_SHIFT 16 49#define SYS_ID_HBI_SHIFT 16
50#define SYS_PROCIDx_HBI_SHIFT 0 50#define SYS_PROCIDx_HBI_SHIFT 0
51 51
52#define SYS_LED_LED(n) (1 << (n))
53
52#define SYS_MCI_CARDIN (1 << 0) 54#define SYS_MCI_CARDIN (1 << 0)
53#define SYS_MCI_WPROT (1 << 1) 55#define SYS_MCI_WPROT (1 << 1)
54 56
@@ -336,34 +338,40 @@ void __init vexpress_sysreg_early_init(void __iomem *base)
336 338
337void __init vexpress_sysreg_of_early_init(void) 339void __init vexpress_sysreg_of_early_init(void)
338{ 340{
339 struct device_node *node = of_find_compatible_node(NULL, NULL, 341 struct device_node *node;
340 "arm,vexpress-sysreg"); 342
343 if (vexpress_sysreg_base)
344 return;
341 345
346 node = of_find_compatible_node(NULL, NULL, "arm,vexpress-sysreg");
342 if (node) { 347 if (node) {
343 vexpress_sysreg_base = of_iomap(node, 0); 348 vexpress_sysreg_base = of_iomap(node, 0);
344 vexpress_sysreg_setup(node); 349 vexpress_sysreg_setup(node);
345 } else {
346 pr_info("vexpress-sysreg: No Device Tree node found.");
347 } 350 }
348} 351}
349 352
350 353
354#define VEXPRESS_SYSREG_GPIO(_name, _reg, _value) \
355 [VEXPRESS_GPIO_##_name] = { \
356 .reg = _reg, \
357 .value = _reg##_##_value, \
358 }
359
351static struct vexpress_sysreg_gpio { 360static struct vexpress_sysreg_gpio {
352 unsigned long reg; 361 unsigned long reg;
353 u32 value; 362 u32 value;
354} vexpress_sysreg_gpios[] = { 363} vexpress_sysreg_gpios[] = {
355 [VEXPRESS_GPIO_MMC_CARDIN] = { 364 VEXPRESS_SYSREG_GPIO(MMC_CARDIN, SYS_MCI, CARDIN),
356 .reg = SYS_MCI, 365 VEXPRESS_SYSREG_GPIO(MMC_WPROT, SYS_MCI, WPROT),
357 .value = SYS_MCI_CARDIN, 366 VEXPRESS_SYSREG_GPIO(FLASH_WPn, SYS_FLASH, WPn),
358 }, 367 VEXPRESS_SYSREG_GPIO(LED0, SYS_LED, LED(0)),
359 [VEXPRESS_GPIO_MMC_WPROT] = { 368 VEXPRESS_SYSREG_GPIO(LED1, SYS_LED, LED(1)),
360 .reg = SYS_MCI, 369 VEXPRESS_SYSREG_GPIO(LED2, SYS_LED, LED(2)),
361 .value = SYS_MCI_WPROT, 370 VEXPRESS_SYSREG_GPIO(LED3, SYS_LED, LED(3)),
362 }, 371 VEXPRESS_SYSREG_GPIO(LED4, SYS_LED, LED(4)),
363 [VEXPRESS_GPIO_FLASH_WPn] = { 372 VEXPRESS_SYSREG_GPIO(LED5, SYS_LED, LED(5)),
364 .reg = SYS_FLASH, 373 VEXPRESS_SYSREG_GPIO(LED6, SYS_LED, LED(6)),
365 .value = SYS_FLASH_WPn, 374 VEXPRESS_SYSREG_GPIO(LED7, SYS_LED, LED(7)),
366 },
367}; 375};
368 376
369static int vexpress_sysreg_gpio_direction_input(struct gpio_chip *chip, 377static int vexpress_sysreg_gpio_direction_input(struct gpio_chip *chip,
@@ -372,12 +380,6 @@ static int vexpress_sysreg_gpio_direction_input(struct gpio_chip *chip,
372 return 0; 380 return 0;
373} 381}
374 382
375static int vexpress_sysreg_gpio_direction_output(struct gpio_chip *chip,
376 unsigned offset, int value)
377{
378 return 0;
379}
380
381static int vexpress_sysreg_gpio_get(struct gpio_chip *chip, 383static int vexpress_sysreg_gpio_get(struct gpio_chip *chip,
382 unsigned offset) 384 unsigned offset)
383{ 385{
@@ -401,6 +403,14 @@ static void vexpress_sysreg_gpio_set(struct gpio_chip *chip,
401 writel(reg_value, vexpress_sysreg_base + gpio->reg); 403 writel(reg_value, vexpress_sysreg_base + gpio->reg);
402} 404}
403 405
406static int vexpress_sysreg_gpio_direction_output(struct gpio_chip *chip,
407 unsigned offset, int value)
408{
409 vexpress_sysreg_gpio_set(chip, offset, value);
410
411 return 0;
412}
413
404static struct gpio_chip vexpress_sysreg_gpio_chip = { 414static struct gpio_chip vexpress_sysreg_gpio_chip = {
405 .label = "vexpress-sysreg", 415 .label = "vexpress-sysreg",
406 .direction_input = vexpress_sysreg_gpio_direction_input, 416 .direction_input = vexpress_sysreg_gpio_direction_input,
@@ -412,6 +422,30 @@ static struct gpio_chip vexpress_sysreg_gpio_chip = {
412}; 422};
413 423
414 424
425#define VEXPRESS_SYSREG_GREEN_LED(_name, _default_trigger, _gpio) \
426 { \
427 .name = "v2m:green:"_name, \
428 .default_trigger = _default_trigger, \
429 .gpio = VEXPRESS_GPIO_##_gpio, \
430 }
431
432struct gpio_led vexpress_sysreg_leds[] = {
433 VEXPRESS_SYSREG_GREEN_LED("user1", "heartbeat", LED0),
434 VEXPRESS_SYSREG_GREEN_LED("user2", "mmc0", LED1),
435 VEXPRESS_SYSREG_GREEN_LED("user3", "cpu0", LED2),
436 VEXPRESS_SYSREG_GREEN_LED("user4", "cpu1", LED3),
437 VEXPRESS_SYSREG_GREEN_LED("user5", "cpu2", LED4),
438 VEXPRESS_SYSREG_GREEN_LED("user6", "cpu3", LED5),
439 VEXPRESS_SYSREG_GREEN_LED("user7", "cpu4", LED6),
440 VEXPRESS_SYSREG_GREEN_LED("user8", "cpu5", LED7),
441};
442
443struct gpio_led_platform_data vexpress_sysreg_leds_pdata = {
444 .num_leds = ARRAY_SIZE(vexpress_sysreg_leds),
445 .leds = vexpress_sysreg_leds,
446};
447
448
415static ssize_t vexpress_sysreg_sys_id_show(struct device *dev, 449static ssize_t vexpress_sysreg_sys_id_show(struct device *dev,
416 struct device_attribute *attr, char *buf) 450 struct device_attribute *attr, char *buf)
417{ 451{
@@ -456,6 +490,10 @@ static int vexpress_sysreg_probe(struct platform_device *pdev)
456 return err; 490 return err;
457 } 491 }
458 492
493 platform_device_register_data(vexpress_sysreg_dev, "leds-gpio",
494 PLATFORM_DEVID_AUTO, &vexpress_sysreg_leds_pdata,
495 sizeof(vexpress_sysreg_leds_pdata));
496
459 vexpress_sysreg_dev = &pdev->dev; 497 vexpress_sysreg_dev = &pdev->dev;
460 498
461 device_create_file(vexpress_sysreg_dev, &dev_attr_sys_id); 499 device_create_file(vexpress_sysreg_dev, &dev_attr_sys_id);
@@ -478,6 +516,7 @@ static struct platform_driver vexpress_sysreg_driver = {
478 516
479static int __init vexpress_sysreg_init(void) 517static int __init vexpress_sysreg_init(void)
480{ 518{
519 vexpress_sysreg_of_early_init();
481 return platform_driver_register(&vexpress_sysreg_driver); 520 return platform_driver_register(&vexpress_sysreg_driver);
482} 521}
483core_initcall(vexpress_sysreg_init); 522core_initcall(vexpress_sysreg_init);
diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c
index 088872ab6338..d754596eb942 100644
--- a/drivers/mfd/wm5102-tables.c
+++ b/drivers/mfd/wm5102-tables.c
@@ -59,12 +59,13 @@ static const struct reg_default wm5102_reva_patch[] = {
59static const struct reg_default wm5102_revb_patch[] = { 59static const struct reg_default wm5102_revb_patch[] = {
60 { 0x80, 0x0003 }, 60 { 0x80, 0x0003 },
61 { 0x081, 0xE022 }, 61 { 0x081, 0xE022 },
62 { 0x410, 0x6080 }, 62 { 0x410, 0x4080 },
63 { 0x418, 0x6080 }, 63 { 0x418, 0x4080 },
64 { 0x420, 0x6080 }, 64 { 0x420, 0x4080 },
65 { 0x428, 0xC000 }, 65 { 0x428, 0xC000 },
66 { 0x441, 0x8014 }, 66 { 0x4B0, 0x0066 },
67 { 0x458, 0x000b }, 67 { 0x458, 0x000b },
68 { 0x212, 0x0000 },
68 { 0x80, 0x0000 }, 69 { 0x80, 0x0000 },
69}; 70};
70 71
@@ -224,11 +225,9 @@ const struct regmap_irq_chip wm5102_irq = {
224static const struct reg_default wm5102_reg_default[] = { 225static const struct reg_default wm5102_reg_default[] = {
225 { 0x00000008, 0x0019 }, /* R8 - Ctrl IF SPI CFG 1 */ 226 { 0x00000008, 0x0019 }, /* R8 - Ctrl IF SPI CFG 1 */
226 { 0x00000009, 0x0001 }, /* R9 - Ctrl IF I2C1 CFG 1 */ 227 { 0x00000009, 0x0001 }, /* R9 - Ctrl IF I2C1 CFG 1 */
227 { 0x0000000D, 0x0000 }, /* R13 - Ctrl IF Status 1 */
228 { 0x00000016, 0x0000 }, /* R22 - Write Sequencer Ctrl 0 */ 228 { 0x00000016, 0x0000 }, /* R22 - Write Sequencer Ctrl 0 */
229 { 0x00000017, 0x0000 }, /* R23 - Write Sequencer Ctrl 1 */ 229 { 0x00000017, 0x0000 }, /* R23 - Write Sequencer Ctrl 1 */
230 { 0x00000018, 0x0000 }, /* R24 - Write Sequencer Ctrl 2 */ 230 { 0x00000018, 0x0000 }, /* R24 - Write Sequencer Ctrl 2 */
231 { 0x0000001A, 0x0000 }, /* R26 - Write Sequencer PROM */
232 { 0x00000020, 0x0000 }, /* R32 - Tone Generator 1 */ 231 { 0x00000020, 0x0000 }, /* R32 - Tone Generator 1 */
233 { 0x00000021, 0x1000 }, /* R33 - Tone Generator 2 */ 232 { 0x00000021, 0x1000 }, /* R33 - Tone Generator 2 */
234 { 0x00000022, 0x0000 }, /* R34 - Tone Generator 3 */ 233 { 0x00000022, 0x0000 }, /* R34 - Tone Generator 3 */
@@ -243,12 +242,14 @@ static const struct reg_default wm5102_reg_default[] = {
243 { 0x00000062, 0x01FF }, /* R98 - Sample Rate Sequence Select 2 */ 242 { 0x00000062, 0x01FF }, /* R98 - Sample Rate Sequence Select 2 */
244 { 0x00000063, 0x01FF }, /* R99 - Sample Rate Sequence Select 3 */ 243 { 0x00000063, 0x01FF }, /* R99 - Sample Rate Sequence Select 3 */
245 { 0x00000064, 0x01FF }, /* R100 - Sample Rate Sequence Select 4 */ 244 { 0x00000064, 0x01FF }, /* R100 - Sample Rate Sequence Select 4 */
246 { 0x00000068, 0x01FF }, /* R104 - Always On Triggers Sequence Select 1 */ 245 { 0x00000066, 0x01FF }, /* R102 - Always On Triggers Sequence Select 1 */
247 { 0x00000069, 0x01FF }, /* R105 - Always On Triggers Sequence Select 2 */ 246 { 0x00000067, 0x01FF }, /* R103 - Always On Triggers Sequence Select 2 */
248 { 0x0000006A, 0x01FF }, /* R106 - Always On Triggers Sequence Select 3 */ 247 { 0x00000068, 0x01FF }, /* R104 - Always On Triggers Sequence Select 3 */
249 { 0x0000006B, 0x01FF }, /* R107 - Always On Triggers Sequence Select 4 */ 248 { 0x00000069, 0x01FF }, /* R105 - Always On Triggers Sequence Select 4 */
250 { 0x0000006C, 0x01FF }, /* R108 - Always On Triggers Sequence Select 5 */ 249 { 0x0000006A, 0x01FF }, /* R106 - Always On Triggers Sequence Select 5 */
251 { 0x0000006D, 0x01FF }, /* R109 - Always On Triggers Sequence Select 6 */ 250 { 0x0000006B, 0x01FF }, /* R107 - Always On Triggers Sequence Select 6 */
251 { 0x0000006E, 0x01FF }, /* R110 - Trigger Sequence Select 32 */
252 { 0x0000006F, 0x01FF }, /* R111 - Trigger Sequence Select 33 */
252 { 0x00000070, 0x0000 }, /* R112 - Comfort Noise Generator */ 253 { 0x00000070, 0x0000 }, /* R112 - Comfort Noise Generator */
253 { 0x00000090, 0x0000 }, /* R144 - Haptics Control 1 */ 254 { 0x00000090, 0x0000 }, /* R144 - Haptics Control 1 */
254 { 0x00000091, 0x7FFF }, /* R145 - Haptics Control 2 */ 255 { 0x00000091, 0x7FFF }, /* R145 - Haptics Control 2 */
@@ -258,13 +259,14 @@ static const struct reg_default wm5102_reg_default[] = {
258 { 0x00000095, 0x0000 }, /* R149 - Haptics phase 2 duration */ 259 { 0x00000095, 0x0000 }, /* R149 - Haptics phase 2 duration */
259 { 0x00000096, 0x0000 }, /* R150 - Haptics phase 3 intensity */ 260 { 0x00000096, 0x0000 }, /* R150 - Haptics phase 3 intensity */
260 { 0x00000097, 0x0000 }, /* R151 - Haptics phase 3 duration */ 261 { 0x00000097, 0x0000 }, /* R151 - Haptics phase 3 duration */
261 { 0x00000100, 0x0001 }, /* R256 - Clock 32k 1 */ 262 { 0x00000100, 0x0002 }, /* R256 - Clock 32k 1 */
262 { 0x00000101, 0x0304 }, /* R257 - System Clock 1 */ 263 { 0x00000101, 0x0304 }, /* R257 - System Clock 1 */
263 { 0x00000102, 0x0011 }, /* R258 - Sample rate 1 */ 264 { 0x00000102, 0x0011 }, /* R258 - Sample rate 1 */
264 { 0x00000103, 0x0011 }, /* R259 - Sample rate 2 */ 265 { 0x00000103, 0x0011 }, /* R259 - Sample rate 2 */
265 { 0x00000104, 0x0011 }, /* R260 - Sample rate 3 */ 266 { 0x00000104, 0x0011 }, /* R260 - Sample rate 3 */
266 { 0x00000112, 0x0305 }, /* R274 - Async clock 1 */ 267 { 0x00000112, 0x0305 }, /* R274 - Async clock 1 */
267 { 0x00000113, 0x0011 }, /* R275 - Async sample rate 1 */ 268 { 0x00000113, 0x0011 }, /* R275 - Async sample rate 1 */
269 { 0x00000114, 0x0011 }, /* R276 - Async sample rate 2 */
268 { 0x00000149, 0x0000 }, /* R329 - Output system clock */ 270 { 0x00000149, 0x0000 }, /* R329 - Output system clock */
269 { 0x0000014A, 0x0000 }, /* R330 - Output async clock */ 271 { 0x0000014A, 0x0000 }, /* R330 - Output async clock */
270 { 0x00000152, 0x0000 }, /* R338 - Rate Estimator 1 */ 272 { 0x00000152, 0x0000 }, /* R338 - Rate Estimator 1 */
@@ -273,13 +275,14 @@ static const struct reg_default wm5102_reg_default[] = {
273 { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */ 275 { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */
274 { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */ 276 { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */
275 { 0x00000161, 0x0000 }, /* R353 - Dynamic Frequency Scaling 1 */ 277 { 0x00000161, 0x0000 }, /* R353 - Dynamic Frequency Scaling 1 */
276 { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */ 278 { 0x00000171, 0x0002 }, /* R369 - FLL1 Control 1 */
277 { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */ 279 { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */
278 { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */ 280 { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */
279 { 0x00000174, 0x007D }, /* R372 - FLL1 Control 4 */ 281 { 0x00000174, 0x007D }, /* R372 - FLL1 Control 4 */
280 { 0x00000175, 0x0004 }, /* R373 - FLL1 Control 5 */ 282 { 0x00000175, 0x0004 }, /* R373 - FLL1 Control 5 */
281 { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */ 283 { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */
282 { 0x00000177, 0x0181 }, /* R375 - FLL1 Loop Filter Test 1 */ 284 { 0x00000177, 0x0181 }, /* R375 - FLL1 Loop Filter Test 1 */
285 { 0x00000178, 0x0000 }, /* R376 - FLL1 NCO Test 0 */
283 { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */ 286 { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */
284 { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */ 287 { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */
285 { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */ 288 { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */
@@ -295,6 +298,7 @@ static const struct reg_default wm5102_reg_default[] = {
295 { 0x00000195, 0x0004 }, /* R405 - FLL2 Control 5 */ 298 { 0x00000195, 0x0004 }, /* R405 - FLL2 Control 5 */
296 { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */ 299 { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */
297 { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */ 300 { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */
301 { 0x00000198, 0x0000 }, /* R408 - FLL2 NCO Test 0 */
298 { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */ 302 { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */
299 { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */ 303 { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */
300 { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */ 304 { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */
@@ -310,8 +314,13 @@ static const struct reg_default wm5102_reg_default[] = {
310 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */ 314 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */
311 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */ 315 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */
312 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */ 316 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */
317 { 0x00000225, 0x0400 }, /* R549 - HP Ctrl 1L */
318 { 0x00000226, 0x0400 }, /* R550 - HP Ctrl 1R */
313 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */ 319 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */
314 { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */ 320 { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */
321 { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */
322 { 0x0000029F, 0x0000 }, /* R671 - Headphone Detect Test */
323 { 0x000002A2, 0x0000 }, /* R674 - Micd Clamp control */
315 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ 324 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */
316 { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */ 325 { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */
317 { 0x000002A5, 0x0000 }, /* R677 - Mic Detect 3 */ 326 { 0x000002A5, 0x0000 }, /* R677 - Mic Detect 3 */
@@ -342,53 +351,44 @@ static const struct reg_default wm5102_reg_default[] = {
342 { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */ 351 { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */
343 { 0x00000408, 0x0000 }, /* R1032 - Output Rate 1 */ 352 { 0x00000408, 0x0000 }, /* R1032 - Output Rate 1 */
344 { 0x00000409, 0x0022 }, /* R1033 - Output Volume Ramp */ 353 { 0x00000409, 0x0022 }, /* R1033 - Output Volume Ramp */
345 { 0x00000410, 0x0080 }, /* R1040 - Output Path Config 1L */ 354 { 0x00000410, 0x4080 }, /* R1040 - Output Path Config 1L */
346 { 0x00000411, 0x0180 }, /* R1041 - DAC Digital Volume 1L */ 355 { 0x00000411, 0x0180 }, /* R1041 - DAC Digital Volume 1L */
347 { 0x00000412, 0x0080 }, /* R1042 - DAC Volume Limit 1L */ 356 { 0x00000412, 0x0081 }, /* R1042 - DAC Volume Limit 1L */
348 { 0x00000413, 0x0001 }, /* R1043 - Noise Gate Select 1L */ 357 { 0x00000413, 0x0001 }, /* R1043 - Noise Gate Select 1L */
349 { 0x00000414, 0x0080 }, /* R1044 - Output Path Config 1R */ 358 { 0x00000414, 0x0080 }, /* R1044 - Output Path Config 1R */
350 { 0x00000415, 0x0180 }, /* R1045 - DAC Digital Volume 1R */ 359 { 0x00000415, 0x0180 }, /* R1045 - DAC Digital Volume 1R */
351 { 0x00000416, 0x0080 }, /* R1046 - DAC Volume Limit 1R */ 360 { 0x00000416, 0x0081 }, /* R1046 - DAC Volume Limit 1R */
352 { 0x00000417, 0x0002 }, /* R1047 - Noise Gate Select 1R */ 361 { 0x00000417, 0x0002 }, /* R1047 - Noise Gate Select 1R */
353 { 0x00000418, 0x0080 }, /* R1048 - Output Path Config 2L */ 362 { 0x00000418, 0x4080 }, /* R1048 - Output Path Config 2L */
354 { 0x00000419, 0x0180 }, /* R1049 - DAC Digital Volume 2L */ 363 { 0x00000419, 0x0180 }, /* R1049 - DAC Digital Volume 2L */
355 { 0x0000041A, 0x0080 }, /* R1050 - DAC Volume Limit 2L */ 364 { 0x0000041A, 0x0081 }, /* R1050 - DAC Volume Limit 2L */
356 { 0x0000041B, 0x0004 }, /* R1051 - Noise Gate Select 2L */ 365 { 0x0000041B, 0x0004 }, /* R1051 - Noise Gate Select 2L */
357 { 0x0000041C, 0x0080 }, /* R1052 - Output Path Config 2R */ 366 { 0x0000041C, 0x0080 }, /* R1052 - Output Path Config 2R */
358 { 0x0000041D, 0x0180 }, /* R1053 - DAC Digital Volume 2R */ 367 { 0x0000041D, 0x0180 }, /* R1053 - DAC Digital Volume 2R */
359 { 0x0000041E, 0x0080 }, /* R1054 - DAC Volume Limit 2R */ 368 { 0x0000041E, 0x0081 }, /* R1054 - DAC Volume Limit 2R */
360 { 0x0000041F, 0x0008 }, /* R1055 - Noise Gate Select 2R */ 369 { 0x0000041F, 0x0008 }, /* R1055 - Noise Gate Select 2R */
361 { 0x00000420, 0x0080 }, /* R1056 - Output Path Config 3L */ 370 { 0x00000420, 0x4080 }, /* R1056 - Output Path Config 3L */
362 { 0x00000421, 0x0180 }, /* R1057 - DAC Digital Volume 3L */ 371 { 0x00000421, 0x0180 }, /* R1057 - DAC Digital Volume 3L */
363 { 0x00000422, 0x0080 }, /* R1058 - DAC Volume Limit 3L */ 372 { 0x00000422, 0x0081 }, /* R1058 - DAC Volume Limit 3L */
364 { 0x00000423, 0x0010 }, /* R1059 - Noise Gate Select 3L */ 373 { 0x00000423, 0x0010 }, /* R1059 - Noise Gate Select 3L */
365 { 0x00000424, 0x0080 }, /* R1060 - Output Path Config 3R */ 374 { 0x00000428, 0xC000 }, /* R1064 - Output Path Config 4L */
366 { 0x00000425, 0x0180 }, /* R1061 - DAC Digital Volume 3R */
367 { 0x00000426, 0x0080 }, /* R1062 - DAC Volume Limit 3R */
368 { 0x00000428, 0x0000 }, /* R1064 - Output Path Config 4L */
369 { 0x00000429, 0x0180 }, /* R1065 - DAC Digital Volume 4L */ 375 { 0x00000429, 0x0180 }, /* R1065 - DAC Digital Volume 4L */
370 { 0x0000042A, 0x0080 }, /* R1066 - Out Volume 4L */ 376 { 0x0000042A, 0x0081 }, /* R1066 - Out Volume 4L */
371 { 0x0000042B, 0x0040 }, /* R1067 - Noise Gate Select 4L */ 377 { 0x0000042B, 0x0040 }, /* R1067 - Noise Gate Select 4L */
372 { 0x0000042C, 0x0000 }, /* R1068 - Output Path Config 4R */
373 { 0x0000042D, 0x0180 }, /* R1069 - DAC Digital Volume 4R */ 378 { 0x0000042D, 0x0180 }, /* R1069 - DAC Digital Volume 4R */
374 { 0x0000042E, 0x0080 }, /* R1070 - Out Volume 4R */ 379 { 0x0000042E, 0x0081 }, /* R1070 - Out Volume 4R */
375 { 0x0000042F, 0x0080 }, /* R1071 - Noise Gate Select 4R */ 380 { 0x0000042F, 0x0080 }, /* R1071 - Noise Gate Select 4R */
376 { 0x00000430, 0x0000 }, /* R1072 - Output Path Config 5L */ 381 { 0x00000430, 0x0000 }, /* R1072 - Output Path Config 5L */
377 { 0x00000431, 0x0180 }, /* R1073 - DAC Digital Volume 5L */ 382 { 0x00000431, 0x0180 }, /* R1073 - DAC Digital Volume 5L */
378 { 0x00000432, 0x0080 }, /* R1074 - DAC Volume Limit 5L */ 383 { 0x00000432, 0x0081 }, /* R1074 - DAC Volume Limit 5L */
379 { 0x00000433, 0x0100 }, /* R1075 - Noise Gate Select 5L */ 384 { 0x00000433, 0x0100 }, /* R1075 - Noise Gate Select 5L */
380 { 0x00000434, 0x0000 }, /* R1076 - Output Path Config 5R */
381 { 0x00000435, 0x0180 }, /* R1077 - DAC Digital Volume 5R */ 385 { 0x00000435, 0x0180 }, /* R1077 - DAC Digital Volume 5R */
382 { 0x00000436, 0x0080 }, /* R1078 - DAC Volume Limit 5R */ 386 { 0x00000436, 0x0081 }, /* R1078 - DAC Volume Limit 5R */
383 { 0x00000437, 0x0200 }, /* R1079 - Noise Gate Select 5R */ 387 { 0x00000437, 0x0200 }, /* R1079 - Noise Gate Select 5R */
384 { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */ 388 { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */
385 { 0x00000458, 0x0001 }, /* R1112 - Noise Gate Control */ 389 { 0x00000458, 0x0001 }, /* R1112 - Noise Gate Control */
386 { 0x00000490, 0x0069 }, /* R1168 - PDM SPK1 CTRL 1 */ 390 { 0x00000490, 0x0069 }, /* R1168 - PDM SPK1 CTRL 1 */
387 { 0x00000491, 0x0000 }, /* R1169 - PDM SPK1 CTRL 2 */ 391 { 0x00000491, 0x0000 }, /* R1169 - PDM SPK1 CTRL 2 */
388 { 0x000004DC, 0x0000 }, /* R1244 - DAC comp 1 */
389 { 0x000004DD, 0x0000 }, /* R1245 - DAC comp 2 */
390 { 0x000004DE, 0x0000 }, /* R1246 - DAC comp 3 */
391 { 0x000004DF, 0x0000 }, /* R1247 - DAC comp 4 */
392 { 0x00000500, 0x000C }, /* R1280 - AIF1 BCLK Ctrl */ 392 { 0x00000500, 0x000C }, /* R1280 - AIF1 BCLK Ctrl */
393 { 0x00000501, 0x0008 }, /* R1281 - AIF1 Tx Pin Ctrl */ 393 { 0x00000501, 0x0008 }, /* R1281 - AIF1 Tx Pin Ctrl */
394 { 0x00000502, 0x0000 }, /* R1282 - AIF1 Rx Pin Ctrl */ 394 { 0x00000502, 0x0000 }, /* R1282 - AIF1 Rx Pin Ctrl */
@@ -416,7 +416,6 @@ static const struct reg_default wm5102_reg_default[] = {
416 { 0x00000518, 0x0007 }, /* R1304 - AIF1 Frame Ctrl 18 */ 416 { 0x00000518, 0x0007 }, /* R1304 - AIF1 Frame Ctrl 18 */
417 { 0x00000519, 0x0000 }, /* R1305 - AIF1 Tx Enables */ 417 { 0x00000519, 0x0000 }, /* R1305 - AIF1 Tx Enables */
418 { 0x0000051A, 0x0000 }, /* R1306 - AIF1 Rx Enables */ 418 { 0x0000051A, 0x0000 }, /* R1306 - AIF1 Rx Enables */
419 { 0x0000051B, 0x0000 }, /* R1307 - AIF1 Force Write */
420 { 0x00000540, 0x000C }, /* R1344 - AIF2 BCLK Ctrl */ 419 { 0x00000540, 0x000C }, /* R1344 - AIF2 BCLK Ctrl */
421 { 0x00000541, 0x0008 }, /* R1345 - AIF2 Tx Pin Ctrl */ 420 { 0x00000541, 0x0008 }, /* R1345 - AIF2 Tx Pin Ctrl */
422 { 0x00000542, 0x0000 }, /* R1346 - AIF2 Rx Pin Ctrl */ 421 { 0x00000542, 0x0000 }, /* R1346 - AIF2 Rx Pin Ctrl */
@@ -432,7 +431,6 @@ static const struct reg_default wm5102_reg_default[] = {
432 { 0x00000552, 0x0001 }, /* R1362 - AIF2 Frame Ctrl 12 */ 431 { 0x00000552, 0x0001 }, /* R1362 - AIF2 Frame Ctrl 12 */
433 { 0x00000559, 0x0000 }, /* R1369 - AIF2 Tx Enables */ 432 { 0x00000559, 0x0000 }, /* R1369 - AIF2 Tx Enables */
434 { 0x0000055A, 0x0000 }, /* R1370 - AIF2 Rx Enables */ 433 { 0x0000055A, 0x0000 }, /* R1370 - AIF2 Rx Enables */
435 { 0x0000055B, 0x0000 }, /* R1371 - AIF2 Force Write */
436 { 0x00000580, 0x000C }, /* R1408 - AIF3 BCLK Ctrl */ 434 { 0x00000580, 0x000C }, /* R1408 - AIF3 BCLK Ctrl */
437 { 0x00000581, 0x0008 }, /* R1409 - AIF3 Tx Pin Ctrl */ 435 { 0x00000581, 0x0008 }, /* R1409 - AIF3 Tx Pin Ctrl */
438 { 0x00000582, 0x0000 }, /* R1410 - AIF3 Rx Pin Ctrl */ 436 { 0x00000582, 0x0000 }, /* R1410 - AIF3 Rx Pin Ctrl */
@@ -448,7 +446,6 @@ static const struct reg_default wm5102_reg_default[] = {
448 { 0x00000592, 0x0001 }, /* R1426 - AIF3 Frame Ctrl 12 */ 446 { 0x00000592, 0x0001 }, /* R1426 - AIF3 Frame Ctrl 12 */
449 { 0x00000599, 0x0000 }, /* R1433 - AIF3 Tx Enables */ 447 { 0x00000599, 0x0000 }, /* R1433 - AIF3 Tx Enables */
450 { 0x0000059A, 0x0000 }, /* R1434 - AIF3 Rx Enables */ 448 { 0x0000059A, 0x0000 }, /* R1434 - AIF3 Rx Enables */
451 { 0x0000059B, 0x0000 }, /* R1435 - AIF3 Force Write */
452 { 0x000005E3, 0x0004 }, /* R1507 - SLIMbus Framer Ref Gear */ 449 { 0x000005E3, 0x0004 }, /* R1507 - SLIMbus Framer Ref Gear */
453 { 0x000005E5, 0x0000 }, /* R1509 - SLIMbus Rates 1 */ 450 { 0x000005E5, 0x0000 }, /* R1509 - SLIMbus Rates 1 */
454 { 0x000005E6, 0x0000 }, /* R1510 - SLIMbus Rates 2 */ 451 { 0x000005E6, 0x0000 }, /* R1510 - SLIMbus Rates 2 */
@@ -772,22 +769,6 @@ static const struct reg_default wm5102_reg_default[] = {
772 { 0x000008CD, 0x0080 }, /* R2253 - DRC1RMIX Input 3 Volume */ 769 { 0x000008CD, 0x0080 }, /* R2253 - DRC1RMIX Input 3 Volume */
773 { 0x000008CE, 0x0000 }, /* R2254 - DRC1RMIX Input 4 Source */ 770 { 0x000008CE, 0x0000 }, /* R2254 - DRC1RMIX Input 4 Source */
774 { 0x000008CF, 0x0080 }, /* R2255 - DRC1RMIX Input 4 Volume */ 771 { 0x000008CF, 0x0080 }, /* R2255 - DRC1RMIX Input 4 Volume */
775 { 0x000008D0, 0x0000 }, /* R2256 - DRC2LMIX Input 1 Source */
776 { 0x000008D1, 0x0080 }, /* R2257 - DRC2LMIX Input 1 Volume */
777 { 0x000008D2, 0x0000 }, /* R2258 - DRC2LMIX Input 2 Source */
778 { 0x000008D3, 0x0080 }, /* R2259 - DRC2LMIX Input 2 Volume */
779 { 0x000008D4, 0x0000 }, /* R2260 - DRC2LMIX Input 3 Source */
780 { 0x000008D5, 0x0080 }, /* R2261 - DRC2LMIX Input 3 Volume */
781 { 0x000008D6, 0x0000 }, /* R2262 - DRC2LMIX Input 4 Source */
782 { 0x000008D7, 0x0080 }, /* R2263 - DRC2LMIX Input 4 Volume */
783 { 0x000008D8, 0x0000 }, /* R2264 - DRC2RMIX Input 1 Source */
784 { 0x000008D9, 0x0080 }, /* R2265 - DRC2RMIX Input 1 Volume */
785 { 0x000008DA, 0x0000 }, /* R2266 - DRC2RMIX Input 2 Source */
786 { 0x000008DB, 0x0080 }, /* R2267 - DRC2RMIX Input 2 Volume */
787 { 0x000008DC, 0x0000 }, /* R2268 - DRC2RMIX Input 3 Source */
788 { 0x000008DD, 0x0080 }, /* R2269 - DRC2RMIX Input 3 Volume */
789 { 0x000008DE, 0x0000 }, /* R2270 - DRC2RMIX Input 4 Source */
790 { 0x000008DF, 0x0080 }, /* R2271 - DRC2RMIX Input 4 Volume */
791 { 0x00000900, 0x0000 }, /* R2304 - HPLP1MIX Input 1 Source */ 772 { 0x00000900, 0x0000 }, /* R2304 - HPLP1MIX Input 1 Source */
792 { 0x00000901, 0x0080 }, /* R2305 - HPLP1MIX Input 1 Volume */ 773 { 0x00000901, 0x0080 }, /* R2305 - HPLP1MIX Input 1 Volume */
793 { 0x00000902, 0x0000 }, /* R2306 - HPLP1MIX Input 2 Source */ 774 { 0x00000902, 0x0000 }, /* R2306 - HPLP1MIX Input 2 Source */
@@ -879,7 +860,7 @@ static const struct reg_default wm5102_reg_default[] = {
879 { 0x00000D1B, 0xFFFF }, /* R3355 - IRQ2 Status 4 Mask */ 860 { 0x00000D1B, 0xFFFF }, /* R3355 - IRQ2 Status 4 Mask */
880 { 0x00000D1C, 0xFFFF }, /* R3356 - IRQ2 Status 5 Mask */ 861 { 0x00000D1C, 0xFFFF }, /* R3356 - IRQ2 Status 5 Mask */
881 { 0x00000D1F, 0x0000 }, /* R3359 - IRQ2 Control */ 862 { 0x00000D1F, 0x0000 }, /* R3359 - IRQ2 Control */
882 { 0x00000D41, 0x0000 }, /* R3393 - ADSP2 IRQ0 */ 863 { 0x00000D50, 0x0000 }, /* R3408 - AOD wkup and trig */
883 { 0x00000D53, 0xFFFF }, /* R3411 - AOD IRQ Mask IRQ1 */ 864 { 0x00000D53, 0xFFFF }, /* R3411 - AOD IRQ Mask IRQ1 */
884 { 0x00000D54, 0xFFFF }, /* R3412 - AOD IRQ Mask IRQ2 */ 865 { 0x00000D54, 0xFFFF }, /* R3412 - AOD IRQ Mask IRQ2 */
885 { 0x00000D56, 0x0000 }, /* R3414 - Jack detect debounce */ 866 { 0x00000D56, 0x0000 }, /* R3414 - Jack detect debounce */
@@ -974,11 +955,6 @@ static const struct reg_default wm5102_reg_default[] = {
974 { 0x00000E82, 0x0018 }, /* R3714 - DRC1 ctrl3 */ 955 { 0x00000E82, 0x0018 }, /* R3714 - DRC1 ctrl3 */
975 { 0x00000E83, 0x0000 }, /* R3715 - DRC1 ctrl4 */ 956 { 0x00000E83, 0x0000 }, /* R3715 - DRC1 ctrl4 */
976 { 0x00000E84, 0x0000 }, /* R3716 - DRC1 ctrl5 */ 957 { 0x00000E84, 0x0000 }, /* R3716 - DRC1 ctrl5 */
977 { 0x00000E89, 0x0018 }, /* R3721 - DRC2 ctrl1 */
978 { 0x00000E8A, 0x0933 }, /* R3722 - DRC2 ctrl2 */
979 { 0x00000E8B, 0x0018 }, /* R3723 - DRC2 ctrl3 */
980 { 0x00000E8C, 0x0000 }, /* R3724 - DRC2 ctrl4 */
981 { 0x00000E8D, 0x0000 }, /* R3725 - DRC2 ctrl5 */
982 { 0x00000EC0, 0x0000 }, /* R3776 - HPLPF1_1 */ 958 { 0x00000EC0, 0x0000 }, /* R3776 - HPLPF1_1 */
983 { 0x00000EC1, 0x0000 }, /* R3777 - HPLPF1_2 */ 959 { 0x00000EC1, 0x0000 }, /* R3777 - HPLPF1_2 */
984 { 0x00000EC4, 0x0000 }, /* R3780 - HPLPF2_1 */ 960 { 0x00000EC4, 0x0000 }, /* R3780 - HPLPF2_1 */
@@ -989,16 +965,12 @@ static const struct reg_default wm5102_reg_default[] = {
989 { 0x00000ECD, 0x0000 }, /* R3789 - HPLPF4_2 */ 965 { 0x00000ECD, 0x0000 }, /* R3789 - HPLPF4_2 */
990 { 0x00000EE0, 0x0000 }, /* R3808 - ASRC_ENABLE */ 966 { 0x00000EE0, 0x0000 }, /* R3808 - ASRC_ENABLE */
991 { 0x00000EE2, 0x0000 }, /* R3810 - ASRC_RATE1 */ 967 { 0x00000EE2, 0x0000 }, /* R3810 - ASRC_RATE1 */
992 { 0x00000EE3, 0x4000 }, /* R3811 - ASRC_RATE2 */
993 { 0x00000EF0, 0x0000 }, /* R3824 - ISRC 1 CTRL 1 */ 968 { 0x00000EF0, 0x0000 }, /* R3824 - ISRC 1 CTRL 1 */
994 { 0x00000EF1, 0x0000 }, /* R3825 - ISRC 1 CTRL 2 */ 969 { 0x00000EF1, 0x0000 }, /* R3825 - ISRC 1 CTRL 2 */
995 { 0x00000EF2, 0x0000 }, /* R3826 - ISRC 1 CTRL 3 */ 970 { 0x00000EF2, 0x0000 }, /* R3826 - ISRC 1 CTRL 3 */
996 { 0x00000EF3, 0x0000 }, /* R3827 - ISRC 2 CTRL 1 */ 971 { 0x00000EF3, 0x0000 }, /* R3827 - ISRC 2 CTRL 1 */
997 { 0x00000EF4, 0x0000 }, /* R3828 - ISRC 2 CTRL 2 */ 972 { 0x00000EF4, 0x0000 }, /* R3828 - ISRC 2 CTRL 2 */
998 { 0x00000EF5, 0x0000 }, /* R3829 - ISRC 2 CTRL 3 */ 973 { 0x00000EF5, 0x0000 }, /* R3829 - ISRC 2 CTRL 3 */
999 { 0x00000EF6, 0x0000 }, /* R3830 - ISRC 3 CTRL 1 */
1000 { 0x00000EF7, 0x0000 }, /* R3831 - ISRC 3 CTRL 2 */
1001 { 0x00000EF8, 0x0000 }, /* R3832 - ISRC 3 CTRL 3 */
1002 { 0x00001100, 0x0010 }, /* R4352 - DSP1 Control 1 */ 974 { 0x00001100, 0x0010 }, /* R4352 - DSP1 Control 1 */
1003 { 0x00001101, 0x0000 }, /* R4353 - DSP1 Clocking 1 */ 975 { 0x00001101, 0x0000 }, /* R4353 - DSP1 Clocking 1 */
1004}; 976};
@@ -1823,17 +1795,24 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg)
1823 case ARIZONA_DSP1_STATUS_1: 1795 case ARIZONA_DSP1_STATUS_1:
1824 case ARIZONA_DSP1_STATUS_2: 1796 case ARIZONA_DSP1_STATUS_2:
1825 case ARIZONA_DSP1_STATUS_3: 1797 case ARIZONA_DSP1_STATUS_3:
1798 case ARIZONA_DSP1_SCRATCH_0:
1799 case ARIZONA_DSP1_SCRATCH_1:
1800 case ARIZONA_DSP1_SCRATCH_2:
1801 case ARIZONA_DSP1_SCRATCH_3:
1826 return true; 1802 return true;
1827 default: 1803 default:
1828 return false; 1804 if ((reg >= 0x100000 && reg < 0x106000) ||
1805 (reg >= 0x180000 && reg < 0x180800) ||
1806 (reg >= 0x190000 && reg < 0x194800) ||
1807 (reg >= 0x1a8000 && reg < 0x1a9800))
1808 return true;
1809 else
1810 return false;
1829 } 1811 }
1830} 1812}
1831 1813
1832static bool wm5102_volatile_register(struct device *dev, unsigned int reg) 1814static bool wm5102_volatile_register(struct device *dev, unsigned int reg)
1833{ 1815{
1834 if (reg > 0xffff)
1835 return true;
1836
1837 switch (reg) { 1816 switch (reg) {
1838 case ARIZONA_SOFTWARE_RESET: 1817 case ARIZONA_SOFTWARE_RESET:
1839 case ARIZONA_DEVICE_REVISION: 1818 case ARIZONA_DEVICE_REVISION:
@@ -1874,15 +1853,25 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg)
1874 case ARIZONA_DSP1_STATUS_1: 1853 case ARIZONA_DSP1_STATUS_1:
1875 case ARIZONA_DSP1_STATUS_2: 1854 case ARIZONA_DSP1_STATUS_2:
1876 case ARIZONA_DSP1_STATUS_3: 1855 case ARIZONA_DSP1_STATUS_3:
1856 case ARIZONA_DSP1_SCRATCH_0:
1857 case ARIZONA_DSP1_SCRATCH_1:
1858 case ARIZONA_DSP1_SCRATCH_2:
1859 case ARIZONA_DSP1_SCRATCH_3:
1877 case ARIZONA_HEADPHONE_DETECT_2: 1860 case ARIZONA_HEADPHONE_DETECT_2:
1878 case ARIZONA_MIC_DETECT_3: 1861 case ARIZONA_MIC_DETECT_3:
1879 return true; 1862 return true;
1880 default: 1863 default:
1881 return false; 1864 if ((reg >= 0x100000 && reg < 0x106000) ||
1865 (reg >= 0x180000 && reg < 0x180800) ||
1866 (reg >= 0x190000 && reg < 0x194800) ||
1867 (reg >= 0x1a8000 && reg < 0x1a9800))
1868 return true;
1869 else
1870 return false;
1882 } 1871 }
1883} 1872}
1884 1873
1885#define WM5102_MAX_REGISTER 0x1a8fff 1874#define WM5102_MAX_REGISTER 0x1a9800
1886 1875
1887const struct regmap_config wm5102_spi_regmap = { 1876const struct regmap_config wm5102_spi_regmap = {
1888 .reg_bits = 32, 1877 .reg_bits = 32,
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 57c488d42d3e..803e93fae56a 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -467,7 +467,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
467 goto err; 467 goto err;
468 } 468 }
469 469
470 ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, 470 ret = devm_regulator_bulk_get(wm8994->dev, wm8994->num_supplies,
471 wm8994->supplies); 471 wm8994->supplies);
472 if (ret != 0) { 472 if (ret != 0) {
473 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); 473 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret);
@@ -478,7 +478,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
478 wm8994->supplies); 478 wm8994->supplies);
479 if (ret != 0) { 479 if (ret != 0) {
480 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); 480 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret);
481 goto err_get; 481 goto err;
482 } 482 }
483 483
484 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); 484 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET);
@@ -658,8 +658,6 @@ err_irq:
658err_enable: 658err_enable:
659 regulator_bulk_disable(wm8994->num_supplies, 659 regulator_bulk_disable(wm8994->num_supplies,
660 wm8994->supplies); 660 wm8994->supplies);
661err_get:
662 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
663err: 661err:
664 mfd_remove_devices(wm8994->dev); 662 mfd_remove_devices(wm8994->dev);
665 return ret; 663 return ret;
@@ -672,7 +670,6 @@ static void wm8994_device_exit(struct wm8994 *wm8994)
672 wm8994_irq_exit(wm8994); 670 wm8994_irq_exit(wm8994);
673 regulator_bulk_disable(wm8994->num_supplies, 671 regulator_bulk_disable(wm8994->num_supplies,
674 wm8994->supplies); 672 wm8994->supplies);
675 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
676} 673}
677 674
678static const struct of_device_id wm8994_of_match[] = { 675static const struct of_device_id wm8994_of_match[] = {
diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 571915dfb218..f74b5adca642 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -1060,26 +1060,6 @@ static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc *host)
1060 return 0; 1060 return 0;
1061} 1061}
1062 1062
1063static int sd_change_bank_voltage(struct realtek_pci_sdmmc *host, u8 voltage)
1064{
1065 struct rtsx_pcr *pcr = host->pcr;
1066 int err;
1067
1068 if (voltage == SD_IO_3V3) {
1069 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
1070 if (err < 0)
1071 return err;
1072 } else if (voltage == SD_IO_1V8) {
1073 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
1074 if (err < 0)
1075 return err;
1076 } else {
1077 return -EINVAL;
1078 }
1079
1080 return 0;
1081}
1082
1083static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios) 1063static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
1084{ 1064{
1085 struct realtek_pci_sdmmc *host = mmc_priv(mmc); 1065 struct realtek_pci_sdmmc *host = mmc_priv(mmc);
@@ -1098,11 +1078,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
1098 rtsx_pci_start_run(pcr); 1078 rtsx_pci_start_run(pcr);
1099 1079
1100 if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) 1080 if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
1101 voltage = SD_IO_3V3; 1081 voltage = OUTPUT_3V3;
1102 else 1082 else
1103 voltage = SD_IO_1V8; 1083 voltage = OUTPUT_1V8;
1104 1084
1105 if (voltage == SD_IO_1V8) { 1085 if (voltage == OUTPUT_1V8) {
1106 err = rtsx_pci_write_register(pcr, 1086 err = rtsx_pci_write_register(pcr,
1107 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 1087 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B);
1108 if (err < 0) 1088 if (err < 0)
@@ -1113,11 +1093,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
1113 goto out; 1093 goto out;
1114 } 1094 }
1115 1095
1116 err = sd_change_bank_voltage(host, voltage); 1096 err = rtsx_pci_switch_output_voltage(pcr, voltage);
1117 if (err < 0) 1097 if (err < 0)
1118 goto out; 1098 goto out;
1119 1099
1120 if (voltage == SD_IO_1V8) { 1100 if (voltage == OUTPUT_1V8) {
1121 err = sd_wait_voltage_stable_2(host); 1101 err = sd_wait_voltage_stable_2(host);
1122 if (err < 0) 1102 if (err < 0)
1123 goto out; 1103 goto out;
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 5233b8f58d77..58607f196c9e 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -960,7 +960,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
960 break; 960 break;
961 case LEC_ACK_ERROR: 961 case LEC_ACK_ERROR:
962 netdev_dbg(dev, "ack error\n"); 962 netdev_dbg(dev, "ack error\n");
963 cf->data[2] |= (CAN_ERR_PROT_LOC_ACK | 963 cf->data[3] |= (CAN_ERR_PROT_LOC_ACK |
964 CAN_ERR_PROT_LOC_ACK_DEL); 964 CAN_ERR_PROT_LOC_ACK_DEL);
965 break; 965 break;
966 case LEC_BIT1_ERROR: 966 case LEC_BIT1_ERROR:
@@ -973,7 +973,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
973 break; 973 break;
974 case LEC_CRC_ERROR: 974 case LEC_CRC_ERROR:
975 netdev_dbg(dev, "CRC error\n"); 975 netdev_dbg(dev, "CRC error\n");
976 cf->data[2] |= (CAN_ERR_PROT_LOC_CRC_SEQ | 976 cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
977 CAN_ERR_PROT_LOC_CRC_DEL); 977 CAN_ERR_PROT_LOC_CRC_DEL);
978 break; 978 break;
979 default: 979 default:
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 7d1748575b1f..5c314a961970 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -560,7 +560,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
560 stats->rx_errors++; 560 stats->rx_errors++;
561 break; 561 break;
562 case PCH_CRC_ERR: 562 case PCH_CRC_ERR:
563 cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ | 563 cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
564 CAN_ERR_PROT_LOC_CRC_DEL; 564 CAN_ERR_PROT_LOC_CRC_DEL;
565 priv->can.can_stats.bus_error++; 565 priv->can.can_stats.bus_error++;
566 stats->rx_errors++; 566 stats->rx_errors++;
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index f898c6363729..300581b24ff3 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -746,12 +746,12 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
746 } 746 }
747 if (err_status & HECC_CANES_CRCE) { 747 if (err_status & HECC_CANES_CRCE) {
748 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE); 748 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE);
749 cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ | 749 cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
750 CAN_ERR_PROT_LOC_CRC_DEL; 750 CAN_ERR_PROT_LOC_CRC_DEL;
751 } 751 }
752 if (err_status & HECC_CANES_ACKE) { 752 if (err_status & HECC_CANES_ACKE) {
753 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE); 753 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE);
754 cf->data[2] |= CAN_ERR_PROT_LOC_ACK | 754 cf->data[3] |= CAN_ERR_PROT_LOC_ACK |
755 CAN_ERR_PROT_LOC_ACK_DEL; 755 CAN_ERR_PROT_LOC_ACK_DEL;
756 } 756 }
757 } 757 }
diff --git a/drivers/net/ethernet/3com/3c574_cs.c b/drivers/net/ethernet/3com/3c574_cs.c
index 66df93638085..ffd8de28a76a 100644
--- a/drivers/net/ethernet/3com/3c574_cs.c
+++ b/drivers/net/ethernet/3com/3c574_cs.c
@@ -432,7 +432,7 @@ static int tc574_config(struct pcmcia_device *link)
432 netdev_info(dev, "%s at io %#3lx, irq %d, hw_addr %pM\n", 432 netdev_info(dev, "%s at io %#3lx, irq %d, hw_addr %pM\n",
433 cardname, dev->base_addr, dev->irq, dev->dev_addr); 433 cardname, dev->base_addr, dev->irq, dev->dev_addr);
434 netdev_info(dev, " %dK FIFO split %s Rx:Tx, %sMII interface.\n", 434 netdev_info(dev, " %dK FIFO split %s Rx:Tx, %sMII interface.\n",
435 8 << config & Ram_size, 435 8 << (config & Ram_size),
436 ram_split[(config & Ram_split) >> Ram_split_shift], 436 ram_split[(config & Ram_split) >> Ram_split_shift],
437 config & Autoselect ? "autoselect " : ""); 437 config & Autoselect ? "autoselect " : "");
438 438
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 78ea90c40e19..bdb086934cd9 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -1283,14 +1283,26 @@ static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
1283 return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg); 1283 return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg);
1284} 1284}
1285 1285
1286#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp) \ 1286static int tg3_phy_toggle_auxctl_smdsp(struct tg3 *tp, bool enable)
1287 tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL, \ 1287{
1288 MII_TG3_AUXCTL_ACTL_SMDSP_ENA | \ 1288 u32 val;
1289 MII_TG3_AUXCTL_ACTL_TX_6DB) 1289 int err;
1290 1290
1291#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp) \ 1291 err = tg3_phy_auxctl_read(tp, MII_TG3_AUXCTL_SHDWSEL_AUXCTL, &val);
1292 tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL, \ 1292
1293 MII_TG3_AUXCTL_ACTL_TX_6DB); 1293 if (err)
1294 return err;
1295 if (enable)
1296
1297 val |= MII_TG3_AUXCTL_ACTL_SMDSP_ENA;
1298 else
1299 val &= ~MII_TG3_AUXCTL_ACTL_SMDSP_ENA;
1300
1301 err = tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL,
1302 val | MII_TG3_AUXCTL_ACTL_TX_6DB);
1303
1304 return err;
1305}
1294 1306
1295static int tg3_bmcr_reset(struct tg3 *tp) 1307static int tg3_bmcr_reset(struct tg3 *tp)
1296{ 1308{
@@ -2223,7 +2235,7 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
2223 2235
2224 otp = tp->phy_otp; 2236 otp = tp->phy_otp;
2225 2237
2226 if (TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) 2238 if (tg3_phy_toggle_auxctl_smdsp(tp, true))
2227 return; 2239 return;
2228 2240
2229 phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT); 2241 phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT);
@@ -2248,7 +2260,7 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
2248 ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT); 2260 ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT);
2249 tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy); 2261 tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy);
2250 2262
2251 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2263 tg3_phy_toggle_auxctl_smdsp(tp, false);
2252} 2264}
2253 2265
2254static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up) 2266static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
@@ -2284,9 +2296,9 @@ static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
2284 2296
2285 if (!tp->setlpicnt) { 2297 if (!tp->setlpicnt) {
2286 if (current_link_up == 1 && 2298 if (current_link_up == 1 &&
2287 !TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2299 !tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2288 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, 0x0000); 2300 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, 0x0000);
2289 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2301 tg3_phy_toggle_auxctl_smdsp(tp, false);
2290 } 2302 }
2291 2303
2292 val = tr32(TG3_CPMU_EEE_MODE); 2304 val = tr32(TG3_CPMU_EEE_MODE);
@@ -2302,11 +2314,11 @@ static void tg3_phy_eee_enable(struct tg3 *tp)
2302 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || 2314 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 ||
2303 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || 2315 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 ||
2304 tg3_flag(tp, 57765_CLASS)) && 2316 tg3_flag(tp, 57765_CLASS)) &&
2305 !TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2317 !tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2306 val = MII_TG3_DSP_TAP26_ALNOKO | 2318 val = MII_TG3_DSP_TAP26_ALNOKO |
2307 MII_TG3_DSP_TAP26_RMRXSTO; 2319 MII_TG3_DSP_TAP26_RMRXSTO;
2308 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, val); 2320 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, val);
2309 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2321 tg3_phy_toggle_auxctl_smdsp(tp, false);
2310 } 2322 }
2311 2323
2312 val = tr32(TG3_CPMU_EEE_MODE); 2324 val = tr32(TG3_CPMU_EEE_MODE);
@@ -2450,7 +2462,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
2450 tg3_writephy(tp, MII_CTRL1000, 2462 tg3_writephy(tp, MII_CTRL1000,
2451 CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER); 2463 CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER);
2452 2464
2453 err = TG3_PHY_AUXCTL_SMDSP_ENABLE(tp); 2465 err = tg3_phy_toggle_auxctl_smdsp(tp, true);
2454 if (err) 2466 if (err)
2455 return err; 2467 return err;
2456 2468
@@ -2471,7 +2483,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
2471 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200); 2483 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
2472 tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0000); 2484 tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0000);
2473 2485
2474 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2486 tg3_phy_toggle_auxctl_smdsp(tp, false);
2475 2487
2476 tg3_writephy(tp, MII_CTRL1000, phy9_orig); 2488 tg3_writephy(tp, MII_CTRL1000, phy9_orig);
2477 2489
@@ -2572,10 +2584,10 @@ static int tg3_phy_reset(struct tg3 *tp)
2572 2584
2573out: 2585out:
2574 if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) && 2586 if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) &&
2575 !TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2587 !tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2576 tg3_phydsp_write(tp, 0x201f, 0x2aaa); 2588 tg3_phydsp_write(tp, 0x201f, 0x2aaa);
2577 tg3_phydsp_write(tp, 0x000a, 0x0323); 2589 tg3_phydsp_write(tp, 0x000a, 0x0323);
2578 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2590 tg3_phy_toggle_auxctl_smdsp(tp, false);
2579 } 2591 }
2580 2592
2581 if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) { 2593 if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) {
@@ -2584,14 +2596,14 @@ out:
2584 } 2596 }
2585 2597
2586 if (tp->phy_flags & TG3_PHYFLG_BER_BUG) { 2598 if (tp->phy_flags & TG3_PHYFLG_BER_BUG) {
2587 if (!TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2599 if (!tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2588 tg3_phydsp_write(tp, 0x000a, 0x310b); 2600 tg3_phydsp_write(tp, 0x000a, 0x310b);
2589 tg3_phydsp_write(tp, 0x201f, 0x9506); 2601 tg3_phydsp_write(tp, 0x201f, 0x9506);
2590 tg3_phydsp_write(tp, 0x401f, 0x14e2); 2602 tg3_phydsp_write(tp, 0x401f, 0x14e2);
2591 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2603 tg3_phy_toggle_auxctl_smdsp(tp, false);
2592 } 2604 }
2593 } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) { 2605 } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) {
2594 if (!TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2606 if (!tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2595 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a); 2607 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a);
2596 if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) { 2608 if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) {
2597 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x110b); 2609 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x110b);
@@ -2600,7 +2612,7 @@ out:
2600 } else 2612 } else
2601 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x010b); 2613 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x010b);
2602 2614
2603 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2615 tg3_phy_toggle_auxctl_smdsp(tp, false);
2604 } 2616 }
2605 } 2617 }
2606 2618
@@ -4009,7 +4021,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
4009 tw32(TG3_CPMU_EEE_MODE, 4021 tw32(TG3_CPMU_EEE_MODE,
4010 tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE); 4022 tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE);
4011 4023
4012 err = TG3_PHY_AUXCTL_SMDSP_ENABLE(tp); 4024 err = tg3_phy_toggle_auxctl_smdsp(tp, true);
4013 if (!err) { 4025 if (!err) {
4014 u32 err2; 4026 u32 err2;
4015 4027
@@ -4042,7 +4054,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
4042 MII_TG3_DSP_CH34TP2_HIBW01); 4054 MII_TG3_DSP_CH34TP2_HIBW01);
4043 } 4055 }
4044 4056
4045 err2 = TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 4057 err2 = tg3_phy_toggle_auxctl_smdsp(tp, false);
4046 if (!err) 4058 if (!err)
4047 err = err2; 4059 err = err2;
4048 } 4060 }
@@ -6950,6 +6962,9 @@ static void tg3_poll_controller(struct net_device *dev)
6950 int i; 6962 int i;
6951 struct tg3 *tp = netdev_priv(dev); 6963 struct tg3 *tp = netdev_priv(dev);
6952 6964
6965 if (tg3_irq_sync(tp))
6966 return;
6967
6953 for (i = 0; i < tp->irq_cnt; i++) 6968 for (i = 0; i < tp->irq_cnt; i++)
6954 tg3_interrupt(tp->napi[i].irq_vec, &tp->napi[i]); 6969 tg3_interrupt(tp->napi[i].irq_vec, &tp->napi[i]);
6955} 6970}
@@ -16367,6 +16382,7 @@ static int tg3_init_one(struct pci_dev *pdev,
16367 tp->pm_cap = pm_cap; 16382 tp->pm_cap = pm_cap;
16368 tp->rx_mode = TG3_DEF_RX_MODE; 16383 tp->rx_mode = TG3_DEF_RX_MODE;
16369 tp->tx_mode = TG3_DEF_TX_MODE; 16384 tp->tx_mode = TG3_DEF_TX_MODE;
16385 tp->irq_sync = 1;
16370 16386
16371 if (tg3_debug > 0) 16387 if (tg3_debug > 0)
16372 tp->msg_enable = tg3_debug; 16388 tp->msg_enable = tg3_debug;
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index b407043ce9b0..f7f02900f650 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -548,6 +548,10 @@ static int desc_get_rx_status(struct xgmac_priv *priv, struct xgmac_dma_desc *p)
548 return -1; 548 return -1;
549 } 549 }
550 550
551 /* All frames should fit into a single buffer */
552 if (!(status & RXDESC_FIRST_SEG) || !(status & RXDESC_LAST_SEG))
553 return -1;
554
551 /* Check if packet has checksum already */ 555 /* Check if packet has checksum already */
552 if ((status & RXDESC_FRAME_TYPE) && (status & RXDESC_EXT_STATUS) && 556 if ((status & RXDESC_FRAME_TYPE) && (status & RXDESC_EXT_STATUS) &&
553 !(ext_status & RXDESC_IP_PAYLOAD_MASK)) 557 !(ext_status & RXDESC_IP_PAYLOAD_MASK))
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index f0718e1a8369..c306df7d4568 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -1994,9 +1994,20 @@ static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1994{ 1994{
1995 const struct port_info *pi = netdev_priv(dev); 1995 const struct port_info *pi = netdev_priv(dev);
1996 struct adapter *adap = pi->adapter; 1996 struct adapter *adap = pi->adapter;
1997 1997 struct sge_rspq *q;
1998 return set_rxq_intr_params(adap, &adap->sge.ethrxq[pi->first_qset].rspq, 1998 int i;
1999 c->rx_coalesce_usecs, c->rx_max_coalesced_frames); 1999 int r = 0;
2000
2001 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) {
2002 q = &adap->sge.ethrxq[i].rspq;
2003 r = set_rxq_intr_params(adap, q, c->rx_coalesce_usecs,
2004 c->rx_max_coalesced_frames);
2005 if (r) {
2006 dev_err(&dev->dev, "failed to set coalesce %d\n", r);
2007 break;
2008 }
2009 }
2010 return r;
2000} 2011}
2001 2012
2002static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) 2013static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
diff --git a/drivers/net/ethernet/intel/ixgbe/Makefile b/drivers/net/ethernet/intel/ixgbe/Makefile
index f3a632bf8d96..687c83d1bdab 100644
--- a/drivers/net/ethernet/intel/ixgbe/Makefile
+++ b/drivers/net/ethernet/intel/ixgbe/Makefile
@@ -32,7 +32,7 @@
32 32
33obj-$(CONFIG_IXGBE) += ixgbe.o 33obj-$(CONFIG_IXGBE) += ixgbe.o
34 34
35ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o ixgbe_debugfs.o\ 35ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \
36 ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \ 36 ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \
37 ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o ixgbe_ptp.o 37 ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o ixgbe_ptp.o
38 38
@@ -40,4 +40,5 @@ ixgbe-$(CONFIG_IXGBE_DCB) += ixgbe_dcb.o ixgbe_dcb_82598.o \
40 ixgbe_dcb_82599.o ixgbe_dcb_nl.o 40 ixgbe_dcb_82599.o ixgbe_dcb_nl.o
41 41
42ixgbe-$(CONFIG_IXGBE_HWMON) += ixgbe_sysfs.o 42ixgbe-$(CONFIG_IXGBE_HWMON) += ixgbe_sysfs.o
43ixgbe-$(CONFIG_DEBUG_FS) += ixgbe_debugfs.o
43ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o 44ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
index 50aa546b8c7a..3504686d3af5 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -24,9 +24,6 @@
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 25
26*******************************************************************************/ 26*******************************************************************************/
27
28#ifdef CONFIG_DEBUG_FS
29
30#include <linux/debugfs.h> 27#include <linux/debugfs.h>
31#include <linux/module.h> 28#include <linux/module.h>
32 29
@@ -277,5 +274,3 @@ void ixgbe_dbg_exit(void)
277{ 274{
278 debugfs_remove_recursive(ixgbe_dbg_root); 275 debugfs_remove_recursive(ixgbe_dbg_root);
279} 276}
280
281#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 1a751c9d09c4..bb9256a1b0a9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -660,11 +660,11 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,
660 break; 660 break;
661 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: 661 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
662 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1; 662 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
663 tsync_rx_mtrl = IXGBE_RXMTRL_V1_SYNC_MSG; 663 tsync_rx_mtrl |= IXGBE_RXMTRL_V1_SYNC_MSG;
664 break; 664 break;
665 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: 665 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
666 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1; 666 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
667 tsync_rx_mtrl = IXGBE_RXMTRL_V1_DELAY_REQ_MSG; 667 tsync_rx_mtrl |= IXGBE_RXMTRL_V1_DELAY_REQ_MSG;
668 break; 668 break;
669 case HWTSTAMP_FILTER_PTP_V2_EVENT: 669 case HWTSTAMP_FILTER_PTP_V2_EVENT:
670 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: 670 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 2b799f4f1c37..6771b69f40d5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -630,10 +630,15 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
630 ring->tx_csum++; 630 ring->tx_csum++;
631 } 631 }
632 632
633 /* Copy dst mac address to wqe */ 633 if (mlx4_is_mfunc(mdev->dev) || priv->validate_loopback) {
634 ethh = (struct ethhdr *)skb->data; 634 /* Copy dst mac address to wqe. This allows loopback in eSwitch,
635 tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest); 635 * so that VFs and PF can communicate with each other
636 tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2)); 636 */
637 ethh = (struct ethhdr *)skb->data;
638 tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest);
639 tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2));
640 }
641
637 /* Handle LSO (TSO) packets */ 642 /* Handle LSO (TSO) packets */
638 if (lso_header_size) { 643 if (lso_header_size) {
639 /* Mark opcode as LSO */ 644 /* Mark opcode as LSO */
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index e1bafffbc3b1..a6542d75374c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1790,15 +1790,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
1790 int i; 1790 int i;
1791 1791
1792 if (msi_x) { 1792 if (msi_x) {
1793 /* In multifunction mode each function gets 2 msi-X vectors 1793 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
1794 * one for data path completions anf the other for asynch events 1794 nreq);
1795 * or command completions */
1796 if (mlx4_is_mfunc(dev)) {
1797 nreq = 2;
1798 } else {
1799 nreq = min_t(int, dev->caps.num_eqs -
1800 dev->caps.reserved_eqs, nreq);
1801 }
1802 1795
1803 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); 1796 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
1804 if (!entries) 1797 if (!entries)
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
index bc165f4d0f65..695667d471a1 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
@@ -144,7 +144,7 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter)
144 buffrag->length, PCI_DMA_TODEVICE); 144 buffrag->length, PCI_DMA_TODEVICE);
145 buffrag->dma = 0ULL; 145 buffrag->dma = 0ULL;
146 } 146 }
147 for (j = 0; j < cmd_buf->frag_count; j++) { 147 for (j = 1; j < cmd_buf->frag_count; j++) {
148 buffrag++; 148 buffrag++;
149 if (buffrag->dma) { 149 if (buffrag->dma) {
150 pci_unmap_page(adapter->pdev, buffrag->dma, 150 pci_unmap_page(adapter->pdev, buffrag->dma,
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 6098fd4adfeb..69e321a65077 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -1963,10 +1963,12 @@ unwind:
1963 while (--i >= 0) { 1963 while (--i >= 0) {
1964 nf = &pbuf->frag_array[i+1]; 1964 nf = &pbuf->frag_array[i+1];
1965 pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE); 1965 pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE);
1966 nf->dma = 0ULL;
1966 } 1967 }
1967 1968
1968 nf = &pbuf->frag_array[0]; 1969 nf = &pbuf->frag_array[0];
1969 pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE); 1970 pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE);
1971 nf->dma = 0ULL;
1970 1972
1971out_err: 1973out_err:
1972 return -ENOMEM; 1974 return -ENOMEM;
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index ed96f309bca8..11702324a071 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1826,8 +1826,6 @@ static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
1826 1826
1827 if (opts2 & RxVlanTag) 1827 if (opts2 & RxVlanTag)
1828 __vlan_hwaccel_put_tag(skb, swab16(opts2 & 0xffff)); 1828 __vlan_hwaccel_put_tag(skb, swab16(opts2 & 0xffff));
1829
1830 desc->opts2 = 0;
1831} 1829}
1832 1830
1833static int rtl8169_gset_tbi(struct net_device *dev, struct ethtool_cmd *cmd) 1831static int rtl8169_gset_tbi(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -6064,8 +6062,6 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
6064 !(status & (RxRWT | RxFOVF)) && 6062 !(status & (RxRWT | RxFOVF)) &&
6065 (dev->features & NETIF_F_RXALL)) 6063 (dev->features & NETIF_F_RXALL))
6066 goto process_pkt; 6064 goto process_pkt;
6067
6068 rtl8169_mark_to_asic(desc, rx_buf_sz);
6069 } else { 6065 } else {
6070 struct sk_buff *skb; 6066 struct sk_buff *skb;
6071 dma_addr_t addr; 6067 dma_addr_t addr;
@@ -6086,16 +6082,14 @@ process_pkt:
6086 if (unlikely(rtl8169_fragmented_frame(status))) { 6082 if (unlikely(rtl8169_fragmented_frame(status))) {
6087 dev->stats.rx_dropped++; 6083 dev->stats.rx_dropped++;
6088 dev->stats.rx_length_errors++; 6084 dev->stats.rx_length_errors++;
6089 rtl8169_mark_to_asic(desc, rx_buf_sz); 6085 goto release_descriptor;
6090 continue;
6091 } 6086 }
6092 6087
6093 skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry], 6088 skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry],
6094 tp, pkt_size, addr); 6089 tp, pkt_size, addr);
6095 rtl8169_mark_to_asic(desc, rx_buf_sz);
6096 if (!skb) { 6090 if (!skb) {
6097 dev->stats.rx_dropped++; 6091 dev->stats.rx_dropped++;
6098 continue; 6092 goto release_descriptor;
6099 } 6093 }
6100 6094
6101 rtl8169_rx_csum(skb, status); 6095 rtl8169_rx_csum(skb, status);
@@ -6111,13 +6105,10 @@ process_pkt:
6111 tp->rx_stats.bytes += pkt_size; 6105 tp->rx_stats.bytes += pkt_size;
6112 u64_stats_update_end(&tp->rx_stats.syncp); 6106 u64_stats_update_end(&tp->rx_stats.syncp);
6113 } 6107 }
6114 6108release_descriptor:
6115 /* Work around for AMD plateform. */ 6109 desc->opts2 = 0;
6116 if ((desc->opts2 & cpu_to_le32(0xfffe000)) && 6110 wmb();
6117 (tp->mac_version == RTL_GIGA_MAC_VER_05)) { 6111 rtl8169_mark_to_asic(desc, rx_buf_sz);
6118 desc->opts2 = 0;
6119 cur_rx++;
6120 }
6121 } 6112 }
6122 6113
6123 count = cur_rx - tp->cur_rx; 6114 count = cur_rx - tp->cur_rx;
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 5fd6f4674326..e6fe0d80d612 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -84,7 +84,7 @@ struct hv_netvsc_packet {
84}; 84};
85 85
86struct netvsc_device_info { 86struct netvsc_device_info {
87 unsigned char mac_adr[6]; 87 unsigned char mac_adr[ETH_ALEN];
88 bool link_state; /* 0 - link up, 1 - link down */ 88 bool link_state; /* 0 - link up, 1 - link down */
89 int ring_size; 89 int ring_size;
90}; 90};
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f825a629a699..8264f0ef7692 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -349,7 +349,7 @@ static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
349 struct net_device_context *ndevctx = netdev_priv(ndev); 349 struct net_device_context *ndevctx = netdev_priv(ndev);
350 struct hv_device *hdev = ndevctx->device_ctx; 350 struct hv_device *hdev = ndevctx->device_ctx;
351 struct sockaddr *addr = p; 351 struct sockaddr *addr = p;
352 char save_adr[14]; 352 char save_adr[ETH_ALEN];
353 unsigned char save_aatype; 353 unsigned char save_aatype;
354 int err; 354 int err;
355 355
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 81f8f9e31db5..fcbf680c3e62 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -77,6 +77,11 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
77 77
78 skb_orphan(skb); 78 skb_orphan(skb);
79 79
80 /* Before queueing this packet to netif_rx(),
81 * make sure dst is refcounted.
82 */
83 skb_dst_force(skb);
84
80 skb->protocol = eth_type_trans(skb, dev); 85 skb->protocol = eth_type_trans(skb, dev);
81 86
82 /* it's OK to use per_cpu_ptr() because BHs are off */ 87 /* it's OK to use per_cpu_ptr() because BHs are off */
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 68a43fe602e7..d3fb97d97cbc 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -822,7 +822,10 @@ static int macvlan_changelink(struct net_device *dev,
822 822
823static size_t macvlan_get_size(const struct net_device *dev) 823static size_t macvlan_get_size(const struct net_device *dev)
824{ 824{
825 return nla_total_size(4); 825 return (0
826 + nla_total_size(4) /* IFLA_MACVLAN_MODE */
827 + nla_total_size(2) /* IFLA_MACVLAN_FLAGS */
828 );
826} 829}
827 830
828static int macvlan_fill_info(struct sk_buff *skb, 831static int macvlan_fill_info(struct sk_buff *skb,
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index d5199cb4caec..b5ddd5077a80 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -36,8 +36,9 @@ MODULE_LICENSE("GPL");
36 36
37/* IP101A/G - IP1001 */ 37/* IP101A/G - IP1001 */
38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */ 38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */
39#define IP1001_RXPHASE_SEL (1<<0) /* Add delay on RX_CLK */
40#define IP1001_TXPHASE_SEL (1<<1) /* Add delay on TX_CLK */
39#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */ 41#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */
40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */
41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ 42#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */
42#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */ 43#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */
43#define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */ 44#define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */
@@ -138,19 +139,24 @@ static int ip1001_config_init(struct phy_device *phydev)
138 if (c < 0) 139 if (c < 0)
139 return c; 140 return c;
140 141
141 /* INTR pin used: speed/link/duplex will cause an interrupt */ 142 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
142 c = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, IP101A_G_IRQ_DEFAULT); 143 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
143 if (c < 0) 144 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
144 return c; 145 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
145 146
146 if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
147 /* Additional delay (2ns) used to adjust RX clock phase
148 * at RGMII interface */
149 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 147 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
150 if (c < 0) 148 if (c < 0)
151 return c; 149 return c;
152 150
153 c |= IP1001_PHASE_SEL_MASK; 151 c &= ~(IP1001_RXPHASE_SEL | IP1001_TXPHASE_SEL);
152
153 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
154 c |= (IP1001_RXPHASE_SEL | IP1001_TXPHASE_SEL);
155 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
156 c |= IP1001_RXPHASE_SEL;
157 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
158 c |= IP1001_TXPHASE_SEL;
159
154 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c); 160 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c);
155 if (c < 0) 161 if (c < 0)
156 return c; 162 return c;
@@ -167,6 +173,11 @@ static int ip101a_g_config_init(struct phy_device *phydev)
167 if (c < 0) 173 if (c < 0)
168 return c; 174 return c;
169 175
176 /* INTR pin used: speed/link/duplex will cause an interrupt */
177 c = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, IP101A_G_IRQ_DEFAULT);
178 if (c < 0)
179 return c;
180
170 /* Enable Auto Power Saving mode */ 181 /* Enable Auto Power Saving mode */
171 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 182 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
172 c |= IP101A_G_APS_ON; 183 c |= IP101A_G_APS_ON;
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 5d2a3f215887..22dec9c7ef05 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -353,15 +353,6 @@ static int m88e1111_config_init(struct phy_device *phydev)
353 int err; 353 int err;
354 int temp; 354 int temp;
355 355
356 /* Enable Fiber/Copper auto selection */
357 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
358 temp &= ~MII_M1111_HWCFG_FIBER_COPPER_AUTO;
359 phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
360
361 temp = phy_read(phydev, MII_BMCR);
362 temp |= BMCR_RESET;
363 phy_write(phydev, MII_BMCR, temp);
364
365 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) || 356 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
366 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) || 357 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
367 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) || 358 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index af372d0957fe..cc09b67c23bc 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -109,11 +109,11 @@ struct tap_filter {
109 unsigned char addr[FLT_EXACT_COUNT][ETH_ALEN]; 109 unsigned char addr[FLT_EXACT_COUNT][ETH_ALEN];
110}; 110};
111 111
112/* 1024 is probably a high enough limit: modern hypervisors seem to support on 112/* DEFAULT_MAX_NUM_RSS_QUEUES were choosed to let the rx/tx queues allocated for
113 * the order of 100-200 CPUs so this leaves us some breathing space if we want 113 * the netdevice to be fit in one page. So we can make sure the success of
114 * to match a queue per guest CPU. 114 * memory allocation. TODO: increase the limit. */
115 */ 115#define MAX_TAP_QUEUES DEFAULT_MAX_NUM_RSS_QUEUES
116#define MAX_TAP_QUEUES 1024 116#define MAX_TAP_FLOWS 4096
117 117
118#define TUN_FLOW_EXPIRE (3 * HZ) 118#define TUN_FLOW_EXPIRE (3 * HZ)
119 119
@@ -185,6 +185,8 @@ struct tun_struct {
185 unsigned long ageing_time; 185 unsigned long ageing_time;
186 unsigned int numdisabled; 186 unsigned int numdisabled;
187 struct list_head disabled; 187 struct list_head disabled;
188 void *security;
189 u32 flow_count;
188}; 190};
189 191
190static inline u32 tun_hashfn(u32 rxhash) 192static inline u32 tun_hashfn(u32 rxhash)
@@ -218,6 +220,7 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun,
218 e->queue_index = queue_index; 220 e->queue_index = queue_index;
219 e->tun = tun; 221 e->tun = tun;
220 hlist_add_head_rcu(&e->hash_link, head); 222 hlist_add_head_rcu(&e->hash_link, head);
223 ++tun->flow_count;
221 } 224 }
222 return e; 225 return e;
223} 226}
@@ -228,6 +231,7 @@ static void tun_flow_delete(struct tun_struct *tun, struct tun_flow_entry *e)
228 e->rxhash, e->queue_index); 231 e->rxhash, e->queue_index);
229 hlist_del_rcu(&e->hash_link); 232 hlist_del_rcu(&e->hash_link);
230 kfree_rcu(e, rcu); 233 kfree_rcu(e, rcu);
234 --tun->flow_count;
231} 235}
232 236
233static void tun_flow_flush(struct tun_struct *tun) 237static void tun_flow_flush(struct tun_struct *tun)
@@ -317,7 +321,8 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
317 e->updated = jiffies; 321 e->updated = jiffies;
318 } else { 322 } else {
319 spin_lock_bh(&tun->lock); 323 spin_lock_bh(&tun->lock);
320 if (!tun_flow_find(head, rxhash)) 324 if (!tun_flow_find(head, rxhash) &&
325 tun->flow_count < MAX_TAP_FLOWS)
321 tun_flow_create(tun, head, rxhash, queue_index); 326 tun_flow_create(tun, head, rxhash, queue_index);
322 327
323 if (!timer_pending(&tun->flow_gc_timer)) 328 if (!timer_pending(&tun->flow_gc_timer))
@@ -490,6 +495,10 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
490 struct tun_file *tfile = file->private_data; 495 struct tun_file *tfile = file->private_data;
491 int err; 496 int err;
492 497
498 err = security_tun_dev_attach(tfile->socket.sk, tun->security);
499 if (err < 0)
500 goto out;
501
493 err = -EINVAL; 502 err = -EINVAL;
494 if (rtnl_dereference(tfile->tun)) 503 if (rtnl_dereference(tfile->tun))
495 goto out; 504 goto out;
@@ -1373,6 +1382,7 @@ static void tun_free_netdev(struct net_device *dev)
1373 1382
1374 BUG_ON(!(list_empty(&tun->disabled))); 1383 BUG_ON(!(list_empty(&tun->disabled)));
1375 tun_flow_uninit(tun); 1384 tun_flow_uninit(tun);
1385 security_tun_dev_free_security(tun->security);
1376 free_netdev(dev); 1386 free_netdev(dev);
1377} 1387}
1378 1388
@@ -1562,7 +1572,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1562 1572
1563 if (tun_not_capable(tun)) 1573 if (tun_not_capable(tun))
1564 return -EPERM; 1574 return -EPERM;
1565 err = security_tun_dev_attach(tfile->socket.sk); 1575 err = security_tun_dev_open(tun->security);
1566 if (err < 0) 1576 if (err < 0)
1567 return err; 1577 return err;
1568 1578
@@ -1577,6 +1587,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1577 else { 1587 else {
1578 char *name; 1588 char *name;
1579 unsigned long flags = 0; 1589 unsigned long flags = 0;
1590 int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ?
1591 MAX_TAP_QUEUES : 1;
1580 1592
1581 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 1593 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
1582 return -EPERM; 1594 return -EPERM;
@@ -1600,8 +1612,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1600 name = ifr->ifr_name; 1612 name = ifr->ifr_name;
1601 1613
1602 dev = alloc_netdev_mqs(sizeof(struct tun_struct), name, 1614 dev = alloc_netdev_mqs(sizeof(struct tun_struct), name,
1603 tun_setup, 1615 tun_setup, queues, queues);
1604 MAX_TAP_QUEUES, MAX_TAP_QUEUES); 1616
1605 if (!dev) 1617 if (!dev)
1606 return -ENOMEM; 1618 return -ENOMEM;
1607 1619
@@ -1619,7 +1631,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1619 1631
1620 spin_lock_init(&tun->lock); 1632 spin_lock_init(&tun->lock);
1621 1633
1622 security_tun_dev_post_create(&tfile->sk); 1634 err = security_tun_dev_alloc_security(&tun->security);
1635 if (err < 0)
1636 goto err_free_dev;
1623 1637
1624 tun_net_init(dev); 1638 tun_net_init(dev);
1625 1639
@@ -1789,10 +1803,14 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
1789 1803
1790 if (ifr->ifr_flags & IFF_ATTACH_QUEUE) { 1804 if (ifr->ifr_flags & IFF_ATTACH_QUEUE) {
1791 tun = tfile->detached; 1805 tun = tfile->detached;
1792 if (!tun) 1806 if (!tun) {
1793 ret = -EINVAL; 1807 ret = -EINVAL;
1794 else 1808 goto unlock;
1795 ret = tun_attach(tun, file); 1809 }
1810 ret = security_tun_dev_attach_queue(tun->security);
1811 if (ret < 0)
1812 goto unlock;
1813 ret = tun_attach(tun, file);
1796 } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) { 1814 } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) {
1797 tun = rtnl_dereference(tfile->tun); 1815 tun = rtnl_dereference(tfile->tun);
1798 if (!tun || !(tun->flags & TUN_TAP_MQ)) 1816 if (!tun || !(tun->flags & TUN_TAP_MQ))
@@ -1802,6 +1820,7 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
1802 } else 1820 } else
1803 ret = -EINVAL; 1821 ret = -EINVAL;
1804 1822
1823unlock:
1805 rtnl_unlock(); 1824 rtnl_unlock();
1806 return ret; 1825 return ret;
1807} 1826}
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index 42f51c71ec1f..248d2dc765a5 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -374,6 +374,21 @@ static const struct driver_info cdc_mbim_info = {
374 .tx_fixup = cdc_mbim_tx_fixup, 374 .tx_fixup = cdc_mbim_tx_fixup,
375}; 375};
376 376
377/* MBIM and NCM devices should not need a ZLP after NTBs with
378 * dwNtbOutMaxSize length. This driver_info is for the exceptional
379 * devices requiring it anyway, allowing them to be supported without
380 * forcing the performance penalty on all the sane devices.
381 */
382static const struct driver_info cdc_mbim_info_zlp = {
383 .description = "CDC MBIM",
384 .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN | FLAG_SEND_ZLP,
385 .bind = cdc_mbim_bind,
386 .unbind = cdc_mbim_unbind,
387 .manage_power = cdc_mbim_manage_power,
388 .rx_fixup = cdc_mbim_rx_fixup,
389 .tx_fixup = cdc_mbim_tx_fixup,
390};
391
377static const struct usb_device_id mbim_devs[] = { 392static const struct usb_device_id mbim_devs[] = {
378 /* This duplicate NCM entry is intentional. MBIM devices can 393 /* This duplicate NCM entry is intentional. MBIM devices can
379 * be disguised as NCM by default, and this is necessary to 394 * be disguised as NCM by default, and this is necessary to
@@ -385,6 +400,10 @@ static const struct usb_device_id mbim_devs[] = {
385 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), 400 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
386 .driver_info = (unsigned long)&cdc_mbim_info, 401 .driver_info = (unsigned long)&cdc_mbim_info,
387 }, 402 },
403 /* Sierra Wireless MC7710 need ZLPs */
404 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68a2, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
405 .driver_info = (unsigned long)&cdc_mbim_info_zlp,
406 },
388 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), 407 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
389 .driver_info = (unsigned long)&cdc_mbim_info, 408 .driver_info = (unsigned long)&cdc_mbim_info,
390 }, 409 },
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92b8e9b..9197b2c72ca3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -435,6 +435,13 @@ advance:
435 len -= temp; 435 len -= temp;
436 } 436 }
437 437
438 /* some buggy devices have an IAD but no CDC Union */
439 if (!ctx->union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {
440 ctx->control = intf;
441 ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);
442 dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n");
443 }
444
438 /* check if we got everything */ 445 /* check if we got everything */
439 if ((ctx->control == NULL) || (ctx->data == NULL) || 446 if ((ctx->control == NULL) || (ctx->data == NULL) ||
440 ((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf)))) 447 ((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))
@@ -497,7 +504,8 @@ advance:
497error2: 504error2:
498 usb_set_intfdata(ctx->control, NULL); 505 usb_set_intfdata(ctx->control, NULL);
499 usb_set_intfdata(ctx->data, NULL); 506 usb_set_intfdata(ctx->data, NULL);
500 usb_driver_release_interface(driver, ctx->data); 507 if (ctx->data != ctx->control)
508 usb_driver_release_interface(driver, ctx->data);
501error: 509error:
502 cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]); 510 cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
503 dev->data[0] = 0; 511 dev->data[0] = 0;
@@ -1155,6 +1163,20 @@ static const struct driver_info wwan_info = {
1155 .tx_fixup = cdc_ncm_tx_fixup, 1163 .tx_fixup = cdc_ncm_tx_fixup,
1156}; 1164};
1157 1165
1166/* Same as wwan_info, but with FLAG_NOARP */
1167static const struct driver_info wwan_noarp_info = {
1168 .description = "Mobile Broadband Network Device (NO ARP)",
1169 .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1170 | FLAG_WWAN | FLAG_NOARP,
1171 .bind = cdc_ncm_bind,
1172 .unbind = cdc_ncm_unbind,
1173 .check_connect = cdc_ncm_check_connect,
1174 .manage_power = usbnet_manage_power,
1175 .status = cdc_ncm_status,
1176 .rx_fixup = cdc_ncm_rx_fixup,
1177 .tx_fixup = cdc_ncm_tx_fixup,
1178};
1179
1158static const struct usb_device_id cdc_devs[] = { 1180static const struct usb_device_id cdc_devs[] = {
1159 /* Ericsson MBM devices like F5521gw */ 1181 /* Ericsson MBM devices like F5521gw */
1160 { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 1182 { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
@@ -1194,6 +1216,13 @@ static const struct usb_device_id cdc_devs[] = {
1194 .driver_info = (unsigned long)&wwan_info, 1216 .driver_info = (unsigned long)&wwan_info,
1195 }, 1217 },
1196 1218
1219 /* Infineon(now Intel) HSPA Modem platform */
1220 { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
1221 USB_CLASS_COMM,
1222 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
1223 .driver_info = (unsigned long)&wwan_noarp_info,
1224 },
1225
1197 /* Generic CDC-NCM devices */ 1226 /* Generic CDC-NCM devices */
1198 { USB_INTERFACE_INFO(USB_CLASS_COMM, 1227 { USB_INTERFACE_INFO(USB_CLASS_COMM,
1199 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), 1228 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 3f554c1149f3..d7e99445518e 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -45,6 +45,12 @@
45#define DM_MCAST_ADDR 0x16 /* 8 bytes */ 45#define DM_MCAST_ADDR 0x16 /* 8 bytes */
46#define DM_GPR_CTRL 0x1e 46#define DM_GPR_CTRL 0x1e
47#define DM_GPR_DATA 0x1f 47#define DM_GPR_DATA 0x1f
48#define DM_CHIP_ID 0x2c
49#define DM_MODE_CTRL 0x91 /* only on dm9620 */
50
51/* chip id values */
52#define ID_DM9601 0
53#define ID_DM9620 1
48 54
49#define DM_MAX_MCAST 64 55#define DM_MAX_MCAST 64
50#define DM_MCAST_SIZE 8 56#define DM_MCAST_SIZE 8
@@ -53,7 +59,6 @@
53#define DM_RX_OVERHEAD 7 /* 3 byte header + 4 byte crc tail */ 59#define DM_RX_OVERHEAD 7 /* 3 byte header + 4 byte crc tail */
54#define DM_TIMEOUT 1000 60#define DM_TIMEOUT 1000
55 61
56
57static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data) 62static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data)
58{ 63{
59 int err; 64 int err;
@@ -84,32 +89,23 @@ static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data)
84 89
85static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) 90static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value)
86{ 91{
87 return usbnet_write_cmd(dev, DM_WRITE_REGS, 92 return usbnet_write_cmd(dev, DM_WRITE_REG,
88 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 93 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
89 value, reg, NULL, 0); 94 value, reg, NULL, 0);
90} 95}
91 96
92static void dm_write_async_helper(struct usbnet *dev, u8 reg, u8 value, 97static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data)
93 u16 length, void *data)
94{ 98{
95 usbnet_write_cmd_async(dev, DM_WRITE_REGS, 99 usbnet_write_cmd_async(dev, DM_WRITE_REGS,
96 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 100 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
97 value, reg, data, length); 101 0, reg, data, length);
98}
99
100static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data)
101{
102 netdev_dbg(dev->net, "dm_write_async() reg=0x%02x length=%d\n", reg, length);
103
104 dm_write_async_helper(dev, reg, 0, length, data);
105} 102}
106 103
107static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value) 104static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value)
108{ 105{
109 netdev_dbg(dev->net, "dm_write_reg_async() reg=0x%02x value=0x%02x\n", 106 usbnet_write_cmd_async(dev, DM_WRITE_REG,
110 reg, value); 107 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
111 108 value, reg, NULL, 0);
112 dm_write_async_helper(dev, reg, value, 0, NULL);
113} 109}
114 110
115static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *value) 111static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *value)
@@ -358,7 +354,7 @@ static const struct net_device_ops dm9601_netdev_ops = {
358static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) 354static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
359{ 355{
360 int ret; 356 int ret;
361 u8 mac[ETH_ALEN]; 357 u8 mac[ETH_ALEN], id;
362 358
363 ret = usbnet_get_endpoints(dev, intf); 359 ret = usbnet_get_endpoints(dev, intf);
364 if (ret) 360 if (ret)
@@ -399,6 +395,24 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
399 __dm9601_set_mac_address(dev); 395 __dm9601_set_mac_address(dev);
400 } 396 }
401 397
398 if (dm_read_reg(dev, DM_CHIP_ID, &id) < 0) {
399 netdev_err(dev->net, "Error reading chip ID\n");
400 ret = -ENODEV;
401 goto out;
402 }
403
404 /* put dm9620 devices in dm9601 mode */
405 if (id == ID_DM9620) {
406 u8 mode;
407
408 if (dm_read_reg(dev, DM_MODE_CTRL, &mode) < 0) {
409 netdev_err(dev->net, "Error reading MODE_CTRL\n");
410 ret = -ENODEV;
411 goto out;
412 }
413 dm_write_reg(dev, DM_MODE_CTRL, mode & 0x7f);
414 }
415
402 /* power up phy */ 416 /* power up phy */
403 dm_write_reg(dev, DM_GPR_CTRL, 1); 417 dm_write_reg(dev, DM_GPR_CTRL, 1);
404 dm_write_reg(dev, DM_GPR_DATA, 0); 418 dm_write_reg(dev, DM_GPR_DATA, 0);
@@ -581,6 +595,10 @@ static const struct usb_device_id products[] = {
581 USB_DEVICE(0x0a46, 0x9000), /* DM9000E */ 595 USB_DEVICE(0x0a46, 0x9000), /* DM9000E */
582 .driver_info = (unsigned long)&dm9601_info, 596 .driver_info = (unsigned long)&dm9601_info,
583 }, 597 },
598 {
599 USB_DEVICE(0x0a46, 0x9620), /* DM9620 USB to Fast Ethernet Adapter */
600 .driver_info = (unsigned long)&dm9601_info,
601 },
584 {}, // END 602 {}, // END
585}; 603};
586 604
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 6a1ca500e612..575a5839ee34 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -433,6 +433,7 @@ static const struct usb_device_id products[] = {
433 {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */ 433 {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */
434 {QMI_FIXED_INTF(0x19d2, 0x0200, 1)}, 434 {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
435 {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */ 435 {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */
436 {QMI_FIXED_INTF(0x19d2, 0x0265, 4)}, /* ONDA MT8205 4G LTE */
436 {QMI_FIXED_INTF(0x19d2, 0x0284, 4)}, /* ZTE MF880 */ 437 {QMI_FIXED_INTF(0x19d2, 0x0284, 4)}, /* ZTE MF880 */
437 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */ 438 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
438 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */ 439 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
@@ -459,6 +460,7 @@ static const struct usb_device_id products[] = {
459 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */ 460 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
460 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */ 461 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
461 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ 462 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
463 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
462 464
463 /* 4. Gobi 1000 devices */ 465 /* 4. Gobi 1000 devices */
464 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 466 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 3d4bf01641b4..f34b2ebee815 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1448,6 +1448,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1448 if ((dev->driver_info->flags & FLAG_WWAN) != 0) 1448 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
1449 strcpy(net->name, "wwan%d"); 1449 strcpy(net->name, "wwan%d");
1450 1450
1451 /* devices that cannot do ARP */
1452 if ((dev->driver_info->flags & FLAG_NOARP) != 0)
1453 net->flags |= IFF_NOARP;
1454
1451 /* maybe the remote can't receive an Ethernet MTU */ 1455 /* maybe the remote can't receive an Ethernet MTU */
1452 if (net->mtu > (dev->hard_mtu - net->hard_header_len)) 1456 if (net->mtu > (dev->hard_mtu - net->hard_header_len))
1453 net->mtu = dev->hard_mtu - net->hard_header_len; 1457 net->mtu = dev->hard_mtu - net->hard_header_len;
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a6fcf15adc4f..35c00c5ea02a 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -26,6 +26,7 @@
26#include <linux/scatterlist.h> 26#include <linux/scatterlist.h>
27#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/cpu.h>
29 30
30static int napi_weight = 128; 31static int napi_weight = 128;
31module_param(napi_weight, int, 0444); 32module_param(napi_weight, int, 0444);
@@ -123,6 +124,12 @@ struct virtnet_info {
123 124
124 /* Does the affinity hint is set for virtqueues? */ 125 /* Does the affinity hint is set for virtqueues? */
125 bool affinity_hint_set; 126 bool affinity_hint_set;
127
128 /* Per-cpu variable to show the mapping from CPU to virtqueue */
129 int __percpu *vq_index;
130
131 /* CPU hot plug notifier */
132 struct notifier_block nb;
126}; 133};
127 134
128struct skb_vnet_hdr { 135struct skb_vnet_hdr {
@@ -1013,32 +1020,75 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
1013 return 0; 1020 return 0;
1014} 1021}
1015 1022
1016static void virtnet_set_affinity(struct virtnet_info *vi, bool set) 1023static void virtnet_clean_affinity(struct virtnet_info *vi, long hcpu)
1017{ 1024{
1018 int i; 1025 int i;
1026 int cpu;
1027
1028 if (vi->affinity_hint_set) {
1029 for (i = 0; i < vi->max_queue_pairs; i++) {
1030 virtqueue_set_affinity(vi->rq[i].vq, -1);
1031 virtqueue_set_affinity(vi->sq[i].vq, -1);
1032 }
1033
1034 vi->affinity_hint_set = false;
1035 }
1036
1037 i = 0;
1038 for_each_online_cpu(cpu) {
1039 if (cpu == hcpu) {
1040 *per_cpu_ptr(vi->vq_index, cpu) = -1;
1041 } else {
1042 *per_cpu_ptr(vi->vq_index, cpu) =
1043 ++i % vi->curr_queue_pairs;
1044 }
1045 }
1046}
1047
1048static void virtnet_set_affinity(struct virtnet_info *vi)
1049{
1050 int i;
1051 int cpu;
1019 1052
1020 /* In multiqueue mode, when the number of cpu is equal to the number of 1053 /* In multiqueue mode, when the number of cpu is equal to the number of
1021 * queue pairs, we let the queue pairs to be private to one cpu by 1054 * queue pairs, we let the queue pairs to be private to one cpu by
1022 * setting the affinity hint to eliminate the contention. 1055 * setting the affinity hint to eliminate the contention.
1023 */ 1056 */
1024 if ((vi->curr_queue_pairs == 1 || 1057 if (vi->curr_queue_pairs == 1 ||
1025 vi->max_queue_pairs != num_online_cpus()) && set) { 1058 vi->max_queue_pairs != num_online_cpus()) {
1026 if (vi->affinity_hint_set) 1059 virtnet_clean_affinity(vi, -1);
1027 set = false; 1060 return;
1028 else
1029 return;
1030 } 1061 }
1031 1062
1032 for (i = 0; i < vi->max_queue_pairs; i++) { 1063 i = 0;
1033 int cpu = set ? i : -1; 1064 for_each_online_cpu(cpu) {
1034 virtqueue_set_affinity(vi->rq[i].vq, cpu); 1065 virtqueue_set_affinity(vi->rq[i].vq, cpu);
1035 virtqueue_set_affinity(vi->sq[i].vq, cpu); 1066 virtqueue_set_affinity(vi->sq[i].vq, cpu);
1067 *per_cpu_ptr(vi->vq_index, cpu) = i;
1068 i++;
1036 } 1069 }
1037 1070
1038 if (set) 1071 vi->affinity_hint_set = true;
1039 vi->affinity_hint_set = true; 1072}
1040 else 1073
1041 vi->affinity_hint_set = false; 1074static int virtnet_cpu_callback(struct notifier_block *nfb,
1075 unsigned long action, void *hcpu)
1076{
1077 struct virtnet_info *vi = container_of(nfb, struct virtnet_info, nb);
1078
1079 switch(action & ~CPU_TASKS_FROZEN) {
1080 case CPU_ONLINE:
1081 case CPU_DOWN_FAILED:
1082 case CPU_DEAD:
1083 virtnet_set_affinity(vi);
1084 break;
1085 case CPU_DOWN_PREPARE:
1086 virtnet_clean_affinity(vi, (long)hcpu);
1087 break;
1088 default:
1089 break;
1090 }
1091 return NOTIFY_OK;
1042} 1092}
1043 1093
1044static void virtnet_get_ringparam(struct net_device *dev, 1094static void virtnet_get_ringparam(struct net_device *dev,
@@ -1082,13 +1132,15 @@ static int virtnet_set_channels(struct net_device *dev,
1082 if (queue_pairs > vi->max_queue_pairs) 1132 if (queue_pairs > vi->max_queue_pairs)
1083 return -EINVAL; 1133 return -EINVAL;
1084 1134
1135 get_online_cpus();
1085 err = virtnet_set_queues(vi, queue_pairs); 1136 err = virtnet_set_queues(vi, queue_pairs);
1086 if (!err) { 1137 if (!err) {
1087 netif_set_real_num_tx_queues(dev, queue_pairs); 1138 netif_set_real_num_tx_queues(dev, queue_pairs);
1088 netif_set_real_num_rx_queues(dev, queue_pairs); 1139 netif_set_real_num_rx_queues(dev, queue_pairs);
1089 1140
1090 virtnet_set_affinity(vi, true); 1141 virtnet_set_affinity(vi);
1091 } 1142 }
1143 put_online_cpus();
1092 1144
1093 return err; 1145 return err;
1094} 1146}
@@ -1127,12 +1179,19 @@ static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
1127 1179
1128/* To avoid contending a lock hold by a vcpu who would exit to host, select the 1180/* To avoid contending a lock hold by a vcpu who would exit to host, select the
1129 * txq based on the processor id. 1181 * txq based on the processor id.
1130 * TODO: handle cpu hotplug.
1131 */ 1182 */
1132static u16 virtnet_select_queue(struct net_device *dev, struct sk_buff *skb) 1183static u16 virtnet_select_queue(struct net_device *dev, struct sk_buff *skb)
1133{ 1184{
1134 int txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) : 1185 int txq;
1135 smp_processor_id(); 1186 struct virtnet_info *vi = netdev_priv(dev);
1187
1188 if (skb_rx_queue_recorded(skb)) {
1189 txq = skb_get_rx_queue(skb);
1190 } else {
1191 txq = *__this_cpu_ptr(vi->vq_index);
1192 if (txq == -1)
1193 txq = 0;
1194 }
1136 1195
1137 while (unlikely(txq >= dev->real_num_tx_queues)) 1196 while (unlikely(txq >= dev->real_num_tx_queues))
1138 txq -= dev->real_num_tx_queues; 1197 txq -= dev->real_num_tx_queues;
@@ -1248,7 +1307,7 @@ static void virtnet_del_vqs(struct virtnet_info *vi)
1248{ 1307{
1249 struct virtio_device *vdev = vi->vdev; 1308 struct virtio_device *vdev = vi->vdev;
1250 1309
1251 virtnet_set_affinity(vi, false); 1310 virtnet_clean_affinity(vi, -1);
1252 1311
1253 vdev->config->del_vqs(vdev); 1312 vdev->config->del_vqs(vdev);
1254 1313
@@ -1371,7 +1430,10 @@ static int init_vqs(struct virtnet_info *vi)
1371 if (ret) 1430 if (ret)
1372 goto err_free; 1431 goto err_free;
1373 1432
1374 virtnet_set_affinity(vi, true); 1433 get_online_cpus();
1434 virtnet_set_affinity(vi);
1435 put_online_cpus();
1436
1375 return 0; 1437 return 0;
1376 1438
1377err_free: 1439err_free:
@@ -1453,6 +1515,10 @@ static int virtnet_probe(struct virtio_device *vdev)
1453 if (vi->stats == NULL) 1515 if (vi->stats == NULL)
1454 goto free; 1516 goto free;
1455 1517
1518 vi->vq_index = alloc_percpu(int);
1519 if (vi->vq_index == NULL)
1520 goto free_stats;
1521
1456 mutex_init(&vi->config_lock); 1522 mutex_init(&vi->config_lock);
1457 vi->config_enable = true; 1523 vi->config_enable = true;
1458 INIT_WORK(&vi->config_work, virtnet_config_changed_work); 1524 INIT_WORK(&vi->config_work, virtnet_config_changed_work);
@@ -1476,7 +1542,7 @@ static int virtnet_probe(struct virtio_device *vdev)
1476 /* Allocate/initialize the rx/tx queues, and invoke find_vqs */ 1542 /* Allocate/initialize the rx/tx queues, and invoke find_vqs */
1477 err = init_vqs(vi); 1543 err = init_vqs(vi);
1478 if (err) 1544 if (err)
1479 goto free_stats; 1545 goto free_index;
1480 1546
1481 netif_set_real_num_tx_queues(dev, 1); 1547 netif_set_real_num_tx_queues(dev, 1);
1482 netif_set_real_num_rx_queues(dev, 1); 1548 netif_set_real_num_rx_queues(dev, 1);
@@ -1499,6 +1565,13 @@ static int virtnet_probe(struct virtio_device *vdev)
1499 } 1565 }
1500 } 1566 }
1501 1567
1568 vi->nb.notifier_call = &virtnet_cpu_callback;
1569 err = register_hotcpu_notifier(&vi->nb);
1570 if (err) {
1571 pr_debug("virtio_net: registering cpu notifier failed\n");
1572 goto free_recv_bufs;
1573 }
1574
1502 /* Assume link up if device can't report link status, 1575 /* Assume link up if device can't report link status,
1503 otherwise get link status from config. */ 1576 otherwise get link status from config. */
1504 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 1577 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) {
@@ -1520,6 +1593,8 @@ free_recv_bufs:
1520free_vqs: 1593free_vqs:
1521 cancel_delayed_work_sync(&vi->refill); 1594 cancel_delayed_work_sync(&vi->refill);
1522 virtnet_del_vqs(vi); 1595 virtnet_del_vqs(vi);
1596free_index:
1597 free_percpu(vi->vq_index);
1523free_stats: 1598free_stats:
1524 free_percpu(vi->stats); 1599 free_percpu(vi->stats);
1525free: 1600free:
@@ -1543,6 +1618,8 @@ static void virtnet_remove(struct virtio_device *vdev)
1543{ 1618{
1544 struct virtnet_info *vi = vdev->priv; 1619 struct virtnet_info *vi = vdev->priv;
1545 1620
1621 unregister_hotcpu_notifier(&vi->nb);
1622
1546 /* Prevent config work handler from accessing the device. */ 1623 /* Prevent config work handler from accessing the device. */
1547 mutex_lock(&vi->config_lock); 1624 mutex_lock(&vi->config_lock);
1548 vi->config_enable = false; 1625 vi->config_enable = false;
@@ -1554,6 +1631,7 @@ static void virtnet_remove(struct virtio_device *vdev)
1554 1631
1555 flush_work(&vi->config_work); 1632 flush_work(&vi->config_work);
1556 1633
1634 free_percpu(vi->vq_index);
1557 free_percpu(vi->stats); 1635 free_percpu(vi->stats);
1558 free_netdev(vi->dev); 1636 free_netdev(vi->dev);
1559} 1637}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 8b0d8dcd7625..56317b0fb6b6 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -976,6 +976,8 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
976 AR_PHY_CL_TAB_1, 976 AR_PHY_CL_TAB_1,
977 AR_PHY_CL_TAB_2 }; 977 AR_PHY_CL_TAB_2 };
978 978
979 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
980
979 if (rtt) { 981 if (rtt) {
980 if (!ar9003_hw_rtt_restore(ah, chan)) 982 if (!ar9003_hw_rtt_restore(ah, chan))
981 run_rtt_cal = true; 983 run_rtt_cal = true;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index ce19c09fa8e8..3afc24bde6d6 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -586,32 +586,19 @@ static void ar9003_hw_init_bb(struct ath_hw *ah,
586 ath9k_hw_synth_delay(ah, chan, synthDelay); 586 ath9k_hw_synth_delay(ah, chan, synthDelay);
587} 587}
588 588
589static void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx) 589void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
590{ 590{
591 switch (rx) { 591 if (ah->caps.tx_chainmask == 5 || ah->caps.rx_chainmask == 5)
592 case 0x5:
593 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP, 592 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
594 AR_PHY_SWAP_ALT_CHAIN); 593 AR_PHY_SWAP_ALT_CHAIN);
595 case 0x3: 594
596 case 0x1: 595 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx);
597 case 0x2: 596 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx);
598 case 0x7:
599 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx);
600 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx);
601 break;
602 default:
603 break;
604 }
605 597
606 if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && (tx == 0x7)) 598 if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && (tx == 0x7))
607 REG_WRITE(ah, AR_SELFGEN_MASK, 0x3); 599 tx = 3;
608 else
609 REG_WRITE(ah, AR_SELFGEN_MASK, tx);
610 600
611 if (tx == 0x5) { 601 REG_WRITE(ah, AR_SELFGEN_MASK, tx);
612 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
613 AR_PHY_SWAP_ALT_CHAIN);
614 }
615} 602}
616 603
617/* 604/*
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 86e26a19efda..42794c546a40 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -317,7 +317,6 @@ struct ath_rx {
317 u32 *rxlink; 317 u32 *rxlink;
318 u32 num_pkts; 318 u32 num_pkts;
319 unsigned int rxfilter; 319 unsigned int rxfilter;
320 spinlock_t rxbuflock;
321 struct list_head rxbuf; 320 struct list_head rxbuf;
322 struct ath_descdma rxdma; 321 struct ath_descdma rxdma;
323 struct ath_buf *rx_bufptr; 322 struct ath_buf *rx_bufptr;
@@ -328,7 +327,6 @@ struct ath_rx {
328 327
329int ath_startrecv(struct ath_softc *sc); 328int ath_startrecv(struct ath_softc *sc);
330bool ath_stoprecv(struct ath_softc *sc); 329bool ath_stoprecv(struct ath_softc *sc);
331void ath_flushrecv(struct ath_softc *sc);
332u32 ath_calcrxfilter(struct ath_softc *sc); 330u32 ath_calcrxfilter(struct ath_softc *sc);
333int ath_rx_init(struct ath_softc *sc, int nbufs); 331int ath_rx_init(struct ath_softc *sc, int nbufs);
334void ath_rx_cleanup(struct ath_softc *sc); 332void ath_rx_cleanup(struct ath_softc *sc);
@@ -646,7 +644,6 @@ void ath_ant_comb_update(struct ath_softc *sc);
646enum sc_op_flags { 644enum sc_op_flags {
647 SC_OP_INVALID, 645 SC_OP_INVALID,
648 SC_OP_BEACONS, 646 SC_OP_BEACONS,
649 SC_OP_RXFLUSH,
650 SC_OP_ANI_RUN, 647 SC_OP_ANI_RUN,
651 SC_OP_PRIM_STA_VIF, 648 SC_OP_PRIM_STA_VIF,
652 SC_OP_HW_RESET, 649 SC_OP_HW_RESET,
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 531fffd801a3..2ca355e94da6 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
147 skb->len, DMA_TO_DEVICE); 147 skb->len, DMA_TO_DEVICE);
148 dev_kfree_skb_any(skb); 148 dev_kfree_skb_any(skb);
149 bf->bf_buf_addr = 0; 149 bf->bf_buf_addr = 0;
150 bf->bf_mpdu = NULL;
150 } 151 }
151 152
152 skb = ieee80211_beacon_get(hw, vif); 153 skb = ieee80211_beacon_get(hw, vif);
@@ -359,7 +360,6 @@ void ath9k_beacon_tasklet(unsigned long data)
359 return; 360 return;
360 361
361 bf = ath9k_beacon_generate(sc->hw, vif); 362 bf = ath9k_beacon_generate(sc->hw, vif);
362 WARN_ON(!bf);
363 363
364 if (sc->beacon.bmisscnt != 0) { 364 if (sc->beacon.bmisscnt != 0) {
365 ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n", 365 ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 13ff9edc2401..e585fc827c50 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -861,7 +861,6 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
861 RXS_ERR("RX-LENGTH-ERR", rx_len_err); 861 RXS_ERR("RX-LENGTH-ERR", rx_len_err);
862 RXS_ERR("RX-OOM-ERR", rx_oom_err); 862 RXS_ERR("RX-OOM-ERR", rx_oom_err);
863 RXS_ERR("RX-RATE-ERR", rx_rate_err); 863 RXS_ERR("RX-RATE-ERR", rx_rate_err);
864 RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
865 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); 864 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
866 865
867 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 866 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index 375c3b46411e..6df2ab62dcb7 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -216,7 +216,6 @@ struct ath_tx_stats {
216 * @rx_oom_err: No. of frames dropped due to OOM issues. 216 * @rx_oom_err: No. of frames dropped due to OOM issues.
217 * @rx_rate_err: No. of frames dropped due to rate errors. 217 * @rx_rate_err: No. of frames dropped due to rate errors.
218 * @rx_too_many_frags_err: Frames dropped due to too-many-frags received. 218 * @rx_too_many_frags_err: Frames dropped due to too-many-frags received.
219 * @rx_drop_rxflush: No. of frames dropped due to RX-FLUSH.
220 * @rx_beacons: No. of beacons received. 219 * @rx_beacons: No. of beacons received.
221 * @rx_frags: No. of rx-fragements received. 220 * @rx_frags: No. of rx-fragements received.
222 */ 221 */
@@ -235,7 +234,6 @@ struct ath_rx_stats {
235 u32 rx_oom_err; 234 u32 rx_oom_err;
236 u32 rx_rate_err; 235 u32 rx_rate_err;
237 u32 rx_too_many_frags_err; 236 u32 rx_too_many_frags_err;
238 u32 rx_drop_rxflush;
239 u32 rx_beacons; 237 u32 rx_beacons;
240 u32 rx_frags; 238 u32 rx_frags;
241}; 239};
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
index 4a9570dfba72..aac4a406a513 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -344,6 +344,8 @@ void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
344 endpoint->ep_callbacks.tx(endpoint->ep_callbacks.priv, 344 endpoint->ep_callbacks.tx(endpoint->ep_callbacks.priv,
345 skb, htc_hdr->endpoint_id, 345 skb, htc_hdr->endpoint_id,
346 txok); 346 txok);
347 } else {
348 kfree_skb(skb);
347 } 349 }
348 } 350 }
349 351
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 7f1a8e91c908..9d26fc56ca56 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -1066,6 +1066,7 @@ void ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain);
1066int ar9003_paprd_init_table(struct ath_hw *ah); 1066int ar9003_paprd_init_table(struct ath_hw *ah);
1067bool ar9003_paprd_is_done(struct ath_hw *ah); 1067bool ar9003_paprd_is_done(struct ath_hw *ah);
1068bool ar9003_is_paprd_enabled(struct ath_hw *ah); 1068bool ar9003_is_paprd_enabled(struct ath_hw *ah);
1069void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
1069 1070
1070/* Hardware family op attach helpers */ 1071/* Hardware family op attach helpers */
1071void ar5008_hw_attach_phy_ops(struct ath_hw *ah); 1072void ar5008_hw_attach_phy_ops(struct ath_hw *ah);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index be30a9af1528..dd91f8fdc01c 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -182,7 +182,7 @@ static void ath_restart_work(struct ath_softc *sc)
182 ath_start_ani(sc); 182 ath_start_ani(sc);
183} 183}
184 184
185static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush) 185static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx)
186{ 186{
187 struct ath_hw *ah = sc->sc_ah; 187 struct ath_hw *ah = sc->sc_ah;
188 bool ret = true; 188 bool ret = true;
@@ -202,14 +202,6 @@ static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
202 if (!ath_drain_all_txq(sc, retry_tx)) 202 if (!ath_drain_all_txq(sc, retry_tx))
203 ret = false; 203 ret = false;
204 204
205 if (!flush) {
206 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
207 ath_rx_tasklet(sc, 1, true);
208 ath_rx_tasklet(sc, 1, false);
209 } else {
210 ath_flushrecv(sc);
211 }
212
213 return ret; 205 return ret;
214} 206}
215 207
@@ -262,11 +254,11 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
262 struct ath_common *common = ath9k_hw_common(ah); 254 struct ath_common *common = ath9k_hw_common(ah);
263 struct ath9k_hw_cal_data *caldata = NULL; 255 struct ath9k_hw_cal_data *caldata = NULL;
264 bool fastcc = true; 256 bool fastcc = true;
265 bool flush = false;
266 int r; 257 int r;
267 258
268 __ath_cancel_work(sc); 259 __ath_cancel_work(sc);
269 260
261 tasklet_disable(&sc->intr_tq);
270 spin_lock_bh(&sc->sc_pcu_lock); 262 spin_lock_bh(&sc->sc_pcu_lock);
271 263
272 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) { 264 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
@@ -276,11 +268,10 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
276 268
277 if (!hchan) { 269 if (!hchan) {
278 fastcc = false; 270 fastcc = false;
279 flush = true;
280 hchan = ah->curchan; 271 hchan = ah->curchan;
281 } 272 }
282 273
283 if (!ath_prepare_reset(sc, retry_tx, flush)) 274 if (!ath_prepare_reset(sc, retry_tx))
284 fastcc = false; 275 fastcc = false;
285 276
286 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n", 277 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
@@ -302,6 +293,8 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
302 293
303out: 294out:
304 spin_unlock_bh(&sc->sc_pcu_lock); 295 spin_unlock_bh(&sc->sc_pcu_lock);
296 tasklet_enable(&sc->intr_tq);
297
305 return r; 298 return r;
306} 299}
307 300
@@ -804,7 +797,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
804 ath9k_hw_cfg_gpio_input(ah, ah->led_pin); 797 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
805 } 798 }
806 799
807 ath_prepare_reset(sc, false, true); 800 ath_prepare_reset(sc, false);
808 801
809 if (sc->rx.frag) { 802 if (sc->rx.frag) {
810 dev_kfree_skb_any(sc->rx.frag); 803 dev_kfree_skb_any(sc->rx.frag);
@@ -1833,6 +1826,9 @@ static u32 fill_chainmask(u32 cap, u32 new)
1833 1826
1834static bool validate_antenna_mask(struct ath_hw *ah, u32 val) 1827static bool validate_antenna_mask(struct ath_hw *ah, u32 val)
1835{ 1828{
1829 if (AR_SREV_9300_20_OR_LATER(ah))
1830 return true;
1831
1836 switch (val & 0x7) { 1832 switch (val & 0x7) {
1837 case 0x1: 1833 case 0x1:
1838 case 0x3: 1834 case 0x3:
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index d4df98a938bf..90752f246970 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -254,8 +254,6 @@ rx_init_fail:
254 254
255static void ath_edma_start_recv(struct ath_softc *sc) 255static void ath_edma_start_recv(struct ath_softc *sc)
256{ 256{
257 spin_lock_bh(&sc->rx.rxbuflock);
258
259 ath9k_hw_rxena(sc->sc_ah); 257 ath9k_hw_rxena(sc->sc_ah);
260 258
261 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP, 259 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP,
@@ -267,8 +265,6 @@ static void ath_edma_start_recv(struct ath_softc *sc)
267 ath_opmode_init(sc); 265 ath_opmode_init(sc);
268 266
269 ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)); 267 ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
270
271 spin_unlock_bh(&sc->rx.rxbuflock);
272} 268}
273 269
274static void ath_edma_stop_recv(struct ath_softc *sc) 270static void ath_edma_stop_recv(struct ath_softc *sc)
@@ -285,8 +281,6 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
285 int error = 0; 281 int error = 0;
286 282
287 spin_lock_init(&sc->sc_pcu_lock); 283 spin_lock_init(&sc->sc_pcu_lock);
288 spin_lock_init(&sc->rx.rxbuflock);
289 clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
290 284
291 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 + 285 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
292 sc->sc_ah->caps.rx_status_len; 286 sc->sc_ah->caps.rx_status_len;
@@ -447,7 +441,6 @@ int ath_startrecv(struct ath_softc *sc)
447 return 0; 441 return 0;
448 } 442 }
449 443
450 spin_lock_bh(&sc->rx.rxbuflock);
451 if (list_empty(&sc->rx.rxbuf)) 444 if (list_empty(&sc->rx.rxbuf))
452 goto start_recv; 445 goto start_recv;
453 446
@@ -468,26 +461,31 @@ start_recv:
468 ath_opmode_init(sc); 461 ath_opmode_init(sc);
469 ath9k_hw_startpcureceive(ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)); 462 ath9k_hw_startpcureceive(ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
470 463
471 spin_unlock_bh(&sc->rx.rxbuflock);
472
473 return 0; 464 return 0;
474} 465}
475 466
467static void ath_flushrecv(struct ath_softc *sc)
468{
469 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
470 ath_rx_tasklet(sc, 1, true);
471 ath_rx_tasklet(sc, 1, false);
472}
473
476bool ath_stoprecv(struct ath_softc *sc) 474bool ath_stoprecv(struct ath_softc *sc)
477{ 475{
478 struct ath_hw *ah = sc->sc_ah; 476 struct ath_hw *ah = sc->sc_ah;
479 bool stopped, reset = false; 477 bool stopped, reset = false;
480 478
481 spin_lock_bh(&sc->rx.rxbuflock);
482 ath9k_hw_abortpcurecv(ah); 479 ath9k_hw_abortpcurecv(ah);
483 ath9k_hw_setrxfilter(ah, 0); 480 ath9k_hw_setrxfilter(ah, 0);
484 stopped = ath9k_hw_stopdmarecv(ah, &reset); 481 stopped = ath9k_hw_stopdmarecv(ah, &reset);
485 482
483 ath_flushrecv(sc);
484
486 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) 485 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
487 ath_edma_stop_recv(sc); 486 ath_edma_stop_recv(sc);
488 else 487 else
489 sc->rx.rxlink = NULL; 488 sc->rx.rxlink = NULL;
490 spin_unlock_bh(&sc->rx.rxbuflock);
491 489
492 if (!(ah->ah_flags & AH_UNPLUGGED) && 490 if (!(ah->ah_flags & AH_UNPLUGGED) &&
493 unlikely(!stopped)) { 491 unlikely(!stopped)) {
@@ -499,15 +497,6 @@ bool ath_stoprecv(struct ath_softc *sc)
499 return stopped && !reset; 497 return stopped && !reset;
500} 498}
501 499
502void ath_flushrecv(struct ath_softc *sc)
503{
504 set_bit(SC_OP_RXFLUSH, &sc->sc_flags);
505 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
506 ath_rx_tasklet(sc, 1, true);
507 ath_rx_tasklet(sc, 1, false);
508 clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
509}
510
511static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb) 500static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
512{ 501{
513 /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */ 502 /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
@@ -744,6 +733,7 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
744 return NULL; 733 return NULL;
745 } 734 }
746 735
736 list_del(&bf->list);
747 if (!bf->bf_mpdu) 737 if (!bf->bf_mpdu)
748 return bf; 738 return bf;
749 739
@@ -1059,16 +1049,12 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1059 dma_type = DMA_FROM_DEVICE; 1049 dma_type = DMA_FROM_DEVICE;
1060 1050
1061 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP; 1051 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
1062 spin_lock_bh(&sc->rx.rxbuflock);
1063 1052
1064 tsf = ath9k_hw_gettsf64(ah); 1053 tsf = ath9k_hw_gettsf64(ah);
1065 tsf_lower = tsf & 0xffffffff; 1054 tsf_lower = tsf & 0xffffffff;
1066 1055
1067 do { 1056 do {
1068 bool decrypt_error = false; 1057 bool decrypt_error = false;
1069 /* If handling rx interrupt and flush is in progress => exit */
1070 if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags) && (flush == 0))
1071 break;
1072 1058
1073 memset(&rs, 0, sizeof(rs)); 1059 memset(&rs, 0, sizeof(rs));
1074 if (edma) 1060 if (edma)
@@ -1111,15 +1097,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1111 1097
1112 ath_debug_stat_rx(sc, &rs); 1098 ath_debug_stat_rx(sc, &rs);
1113 1099
1114 /*
1115 * If we're asked to flush receive queue, directly
1116 * chain it back at the queue without processing it.
1117 */
1118 if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags)) {
1119 RX_STAT_INC(rx_drop_rxflush);
1120 goto requeue_drop_frag;
1121 }
1122
1123 memset(rxs, 0, sizeof(struct ieee80211_rx_status)); 1100 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
1124 1101
1125 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; 1102 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
@@ -1254,19 +1231,18 @@ requeue_drop_frag:
1254 sc->rx.frag = NULL; 1231 sc->rx.frag = NULL;
1255 } 1232 }
1256requeue: 1233requeue:
1234 list_add_tail(&bf->list, &sc->rx.rxbuf);
1235 if (flush)
1236 continue;
1237
1257 if (edma) { 1238 if (edma) {
1258 list_add_tail(&bf->list, &sc->rx.rxbuf);
1259 ath_rx_edma_buf_link(sc, qtype); 1239 ath_rx_edma_buf_link(sc, qtype);
1260 } else { 1240 } else {
1261 list_move_tail(&bf->list, &sc->rx.rxbuf);
1262 ath_rx_buf_link(sc, bf); 1241 ath_rx_buf_link(sc, bf);
1263 if (!flush) 1242 ath9k_hw_rxena(ah);
1264 ath9k_hw_rxena(ah);
1265 } 1243 }
1266 } while (1); 1244 } while (1);
1267 1245
1268 spin_unlock_bh(&sc->rx.rxbuflock);
1269
1270 if (!(ah->imask & ATH9K_INT_RXEOL)) { 1246 if (!(ah->imask & ATH9K_INT_RXEOL)) {
1271 ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN); 1247 ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
1272 ath9k_hw_set_interrupts(ah); 1248 ath9k_hw_set_interrupts(ah);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 1fbd8ecbe2ea..0f71d1d4339d 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -1407,9 +1407,10 @@ void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
1407#endif 1407#endif
1408 t->ms = ms; 1408 t->ms = ms;
1409 t->periodic = (bool) periodic; 1409 t->periodic = (bool) periodic;
1410 t->set = true; 1410 if (!t->set) {
1411 1411 t->set = true;
1412 atomic_inc(&t->wl->callbacks); 1412 atomic_inc(&t->wl->callbacks);
1413 }
1413 1414
1414 ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms)); 1415 ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
1415} 1416}
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index 7e16d10a7f14..90b8970eadf0 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -3958,17 +3958,21 @@ il_connection_init_rx_config(struct il_priv *il)
3958 3958
3959 memset(&il->staging, 0, sizeof(il->staging)); 3959 memset(&il->staging, 0, sizeof(il->staging));
3960 3960
3961 if (!il->vif) { 3961 switch (il->iw_mode) {
3962 case NL80211_IFTYPE_UNSPECIFIED:
3962 il->staging.dev_type = RXON_DEV_TYPE_ESS; 3963 il->staging.dev_type = RXON_DEV_TYPE_ESS;
3963 } else if (il->vif->type == NL80211_IFTYPE_STATION) { 3964 break;
3965 case NL80211_IFTYPE_STATION:
3964 il->staging.dev_type = RXON_DEV_TYPE_ESS; 3966 il->staging.dev_type = RXON_DEV_TYPE_ESS;
3965 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; 3967 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
3966 } else if (il->vif->type == NL80211_IFTYPE_ADHOC) { 3968 break;
3969 case NL80211_IFTYPE_ADHOC:
3967 il->staging.dev_type = RXON_DEV_TYPE_IBSS; 3970 il->staging.dev_type = RXON_DEV_TYPE_IBSS;
3968 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; 3971 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
3969 il->staging.filter_flags = 3972 il->staging.filter_flags =
3970 RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK; 3973 RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
3971 } else { 3974 break;
3975 default:
3972 IL_ERR("Unsupported interface type %d\n", il->vif->type); 3976 IL_ERR("Unsupported interface type %d\n", il->vif->type);
3973 return; 3977 return;
3974 } 3978 }
@@ -4550,8 +4554,7 @@ out:
4550EXPORT_SYMBOL(il_mac_add_interface); 4554EXPORT_SYMBOL(il_mac_add_interface);
4551 4555
4552static void 4556static void
4553il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, 4557il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif)
4554 bool mode_change)
4555{ 4558{
4556 lockdep_assert_held(&il->mutex); 4559 lockdep_assert_held(&il->mutex);
4557 4560
@@ -4560,9 +4563,7 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
4560 il_force_scan_end(il); 4563 il_force_scan_end(il);
4561 } 4564 }
4562 4565
4563 if (!mode_change) 4566 il_set_mode(il);
4564 il_set_mode(il);
4565
4566} 4567}
4567 4568
4568void 4569void
@@ -4575,8 +4576,8 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4575 4576
4576 WARN_ON(il->vif != vif); 4577 WARN_ON(il->vif != vif);
4577 il->vif = NULL; 4578 il->vif = NULL;
4578 4579 il->iw_mode = NL80211_IFTYPE_UNSPECIFIED;
4579 il_teardown_interface(il, vif, false); 4580 il_teardown_interface(il, vif);
4580 memset(il->bssid, 0, ETH_ALEN); 4581 memset(il->bssid, 0, ETH_ALEN);
4581 4582
4582 D_MAC80211("leave\n"); 4583 D_MAC80211("leave\n");
@@ -4685,18 +4686,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4685 } 4686 }
4686 4687
4687 /* success */ 4688 /* success */
4688 il_teardown_interface(il, vif, true);
4689 vif->type = newtype; 4689 vif->type = newtype;
4690 vif->p2p = false; 4690 vif->p2p = false;
4691 err = il_set_mode(il); 4691 il->iw_mode = newtype;
4692 WARN_ON(err); 4692 il_teardown_interface(il, vif);
4693 /*
4694 * We've switched internally, but submitting to the
4695 * device may have failed for some reason. Mask this
4696 * error, because otherwise mac80211 will not switch
4697 * (and set the interface type back) and we'll be
4698 * out of sync with it.
4699 */
4700 err = 0; 4693 err = 0;
4701 4694
4702out: 4695out:
diff --git a/drivers/net/wireless/iwlwifi/dvm/tx.c b/drivers/net/wireless/iwlwifi/dvm/tx.c
index a790599fe2c2..31534f7c0548 100644
--- a/drivers/net/wireless/iwlwifi/dvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/tx.c
@@ -1079,6 +1079,8 @@ static void iwlagn_set_tx_status(struct iwl_priv *priv,
1079{ 1079{
1080 u16 status = le16_to_cpu(tx_resp->status.status); 1080 u16 status = le16_to_cpu(tx_resp->status.status);
1081 1081
1082 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
1083
1082 info->status.rates[0].count = tx_resp->failure_frame + 1; 1084 info->status.rates[0].count = tx_resp->failure_frame + 1;
1083 info->flags |= iwl_tx_status_to_mac80211(status); 1085 info->flags |= iwl_tx_status_to_mac80211(status);
1084 iwlagn_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), 1086 iwlagn_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags),
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index efe525be27dd..cdb11b3964e2 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1459,7 +1459,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1459 struct cfg80211_ssid req_ssid; 1459 struct cfg80211_ssid req_ssid;
1460 int ret, auth_type = 0; 1460 int ret, auth_type = 0;
1461 struct cfg80211_bss *bss = NULL; 1461 struct cfg80211_bss *bss = NULL;
1462 u8 is_scanning_required = 0, config_bands = 0; 1462 u8 is_scanning_required = 0;
1463 1463
1464 memset(&req_ssid, 0, sizeof(struct cfg80211_ssid)); 1464 memset(&req_ssid, 0, sizeof(struct cfg80211_ssid));
1465 1465
@@ -1478,19 +1478,6 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1478 /* disconnect before try to associate */ 1478 /* disconnect before try to associate */
1479 mwifiex_deauthenticate(priv, NULL); 1479 mwifiex_deauthenticate(priv, NULL);
1480 1480
1481 if (channel) {
1482 if (mode == NL80211_IFTYPE_STATION) {
1483 if (channel->band == IEEE80211_BAND_2GHZ)
1484 config_bands = BAND_B | BAND_G | BAND_GN;
1485 else
1486 config_bands = BAND_A | BAND_AN;
1487
1488 if (!((config_bands | priv->adapter->fw_bands) &
1489 ~priv->adapter->fw_bands))
1490 priv->adapter->config_bands = config_bands;
1491 }
1492 }
1493
1494 /* As this is new association, clear locally stored 1481 /* As this is new association, clear locally stored
1495 * keys and security related flags */ 1482 * keys and security related flags */
1496 priv->sec_info.wpa_enabled = false; 1483 priv->sec_info.wpa_enabled = false;
@@ -1707,7 +1694,7 @@ static int mwifiex_set_ibss_params(struct mwifiex_private *priv,
1707 1694
1708 if (cfg80211_get_chandef_type(&params->chandef) != 1695 if (cfg80211_get_chandef_type(&params->chandef) !=
1709 NL80211_CHAN_NO_HT) 1696 NL80211_CHAN_NO_HT)
1710 config_bands |= BAND_GN; 1697 config_bands |= BAND_G | BAND_GN;
1711 } else { 1698 } else {
1712 if (cfg80211_get_chandef_type(&params->chandef) == 1699 if (cfg80211_get_chandef_type(&params->chandef) ==
1713 NL80211_CHAN_NO_HT) 1700 NL80211_CHAN_NO_HT)
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 13fbc4eb1595..b879e1338a54 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -161,7 +161,7 @@ static int mwifiex_pcie_suspend(struct pci_dev *pdev, pm_message_t state)
161 161
162 if (pdev) { 162 if (pdev) {
163 card = (struct pcie_service_card *) pci_get_drvdata(pdev); 163 card = (struct pcie_service_card *) pci_get_drvdata(pdev);
164 if (!card || card->adapter) { 164 if (!card || !card->adapter) {
165 pr_err("Card or adapter structure is not valid\n"); 165 pr_err("Card or adapter structure is not valid\n");
166 return 0; 166 return 0;
167 } 167 }
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index 60e88b58039d..f542bb8ccbc8 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -283,6 +283,20 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
283 if (ret) 283 if (ret)
284 goto done; 284 goto done;
285 285
286 if (bss_desc) {
287 u8 config_bands = 0;
288
289 if (mwifiex_band_to_radio_type((u8) bss_desc->bss_band)
290 == HostCmd_SCAN_RADIO_TYPE_BG)
291 config_bands = BAND_B | BAND_G | BAND_GN;
292 else
293 config_bands = BAND_A | BAND_AN;
294
295 if (!((config_bands | adapter->fw_bands) &
296 ~adapter->fw_bands))
297 adapter->config_bands = config_bands;
298 }
299
286 ret = mwifiex_check_network_compatibility(priv, bss_desc); 300 ret = mwifiex_check_network_compatibility(priv, bss_desc);
287 if (ret) 301 if (ret)
288 goto done; 302 goto done;
diff --git a/drivers/net/wireless/rtlwifi/Kconfig b/drivers/net/wireless/rtlwifi/Kconfig
index 21b1bbb93a7e..b80bc4612581 100644
--- a/drivers/net/wireless/rtlwifi/Kconfig
+++ b/drivers/net/wireless/rtlwifi/Kconfig
@@ -57,12 +57,12 @@ config RTL8192CU
57 57
58config RTLWIFI 58config RTLWIFI
59 tristate 59 tristate
60 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE 60 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE || RTL8723AE
61 default m 61 default m
62 62
63config RTLWIFI_DEBUG 63config RTLWIFI_DEBUG
64 bool "Additional debugging output" 64 bool "Additional debugging output"
65 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE 65 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE || RTL8723AE
66 default y 66 default y
67 67
68config RTL8192C_COMMON 68config RTL8192C_COMMON
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index c31aeb01bb00..efaecefe3f8c 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -181,7 +181,6 @@ config PINCTRL_COH901
181 181
182config PINCTRL_SAMSUNG 182config PINCTRL_SAMSUNG
183 bool 183 bool
184 depends on OF && GPIOLIB
185 select PINMUX 184 select PINMUX
186 select PINCONF 185 select PINCONF
187 186
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index 69aba3697287..428ea96a94d3 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -588,7 +588,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
588{ 588{
589 const struct of_device_id *match = 589 const struct of_device_id *match =
590 of_match_device(dove_pinctrl_of_match, &pdev->dev); 590 of_match_device(dove_pinctrl_of_match, &pdev->dev);
591 pdev->dev.platform_data = match->data; 591 pdev->dev.platform_data = (void *)match->data;
592 592
593 /* 593 /*
594 * General MPP Configuration Register is part of pdma registers. 594 * General MPP Configuration Register is part of pdma registers.
diff --git a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
index f12084e18057..cdd483df673e 100644
--- a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
+++ b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
@@ -66,9 +66,9 @@ static struct mvebu_mpp_mode mv88f6xxx_mpp_modes[] = {
66 MPP_VAR_FUNCTION(0x5, "sata0", "act", V(0, 1, 1, 1, 1, 0)), 66 MPP_VAR_FUNCTION(0x5, "sata0", "act", V(0, 1, 1, 1, 1, 0)),
67 MPP_VAR_FUNCTION(0xb, "lcd", "vsync", V(0, 0, 0, 0, 1, 0))), 67 MPP_VAR_FUNCTION(0xb, "lcd", "vsync", V(0, 0, 0, 0, 1, 0))),
68 MPP_MODE(6, 68 MPP_MODE(6,
69 MPP_VAR_FUNCTION(0x0, "sysrst", "out", V(1, 1, 1, 1, 1, 1)), 69 MPP_VAR_FUNCTION(0x1, "sysrst", "out", V(1, 1, 1, 1, 1, 1)),
70 MPP_VAR_FUNCTION(0x1, "spi", "mosi", V(1, 1, 1, 1, 1, 1)), 70 MPP_VAR_FUNCTION(0x2, "spi", "mosi", V(1, 1, 1, 1, 1, 1)),
71 MPP_VAR_FUNCTION(0x2, "ptp", "trig", V(1, 1, 1, 1, 0, 0))), 71 MPP_VAR_FUNCTION(0x3, "ptp", "trig", V(1, 1, 1, 1, 0, 0))),
72 MPP_MODE(7, 72 MPP_MODE(7,
73 MPP_VAR_FUNCTION(0x0, "gpo", NULL, V(1, 1, 1, 1, 1, 1)), 73 MPP_VAR_FUNCTION(0x0, "gpo", NULL, V(1, 1, 1, 1, 1, 1)),
74 MPP_VAR_FUNCTION(0x1, "pex", "rsto", V(1, 1, 1, 1, 0, 1)), 74 MPP_VAR_FUNCTION(0x1, "pex", "rsto", V(1, 1, 1, 1, 0, 1)),
@@ -458,7 +458,7 @@ static int kirkwood_pinctrl_probe(struct platform_device *pdev)
458{ 458{
459 const struct of_device_id *match = 459 const struct of_device_id *match =
460 of_match_device(kirkwood_pinctrl_of_match, &pdev->dev); 460 of_match_device(kirkwood_pinctrl_of_match, &pdev->dev);
461 pdev->dev.platform_data = match->data; 461 pdev->dev.platform_data = (void *)match->data;
462 return mvebu_pinctrl_probe(pdev); 462 return mvebu_pinctrl_probe(pdev);
463} 463}
464 464
diff --git a/drivers/pinctrl/pinctrl-exynos5440.c b/drivers/pinctrl/pinctrl-exynos5440.c
index de05b64f0da6..142729914c34 100644
--- a/drivers/pinctrl/pinctrl-exynos5440.c
+++ b/drivers/pinctrl/pinctrl-exynos5440.c
@@ -599,7 +599,7 @@ static int exynos5440_gpio_direction_output(struct gpio_chip *gc, unsigned offse
599} 599}
600 600
601/* parse the pin numbers listed in the 'samsung,exynos5440-pins' property */ 601/* parse the pin numbers listed in the 'samsung,exynos5440-pins' property */
602static int __init exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev, 602static int exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev,
603 struct device_node *cfg_np, unsigned int **pin_list, 603 struct device_node *cfg_np, unsigned int **pin_list,
604 unsigned int *npins) 604 unsigned int *npins)
605{ 605{
@@ -630,7 +630,7 @@ static int __init exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev,
630 * Parse the information about all the available pin groups and pin functions 630 * Parse the information about all the available pin groups and pin functions
631 * from device node of the pin-controller. 631 * from device node of the pin-controller.
632 */ 632 */
633static int __init exynos5440_pinctrl_parse_dt(struct platform_device *pdev, 633static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev,
634 struct exynos5440_pinctrl_priv_data *priv) 634 struct exynos5440_pinctrl_priv_data *priv)
635{ 635{
636 struct device *dev = &pdev->dev; 636 struct device *dev = &pdev->dev;
@@ -723,7 +723,7 @@ static int __init exynos5440_pinctrl_parse_dt(struct platform_device *pdev,
723} 723}
724 724
725/* register the pinctrl interface with the pinctrl subsystem */ 725/* register the pinctrl interface with the pinctrl subsystem */
726static int __init exynos5440_pinctrl_register(struct platform_device *pdev, 726static int exynos5440_pinctrl_register(struct platform_device *pdev,
727 struct exynos5440_pinctrl_priv_data *priv) 727 struct exynos5440_pinctrl_priv_data *priv)
728{ 728{
729 struct device *dev = &pdev->dev; 729 struct device *dev = &pdev->dev;
@@ -798,7 +798,7 @@ static int __init exynos5440_pinctrl_register(struct platform_device *pdev,
798} 798}
799 799
800/* register the gpiolib interface with the gpiolib subsystem */ 800/* register the gpiolib interface with the gpiolib subsystem */
801static int __init exynos5440_gpiolib_register(struct platform_device *pdev, 801static int exynos5440_gpiolib_register(struct platform_device *pdev,
802 struct exynos5440_pinctrl_priv_data *priv) 802 struct exynos5440_pinctrl_priv_data *priv)
803{ 803{
804 struct gpio_chip *gc; 804 struct gpio_chip *gc;
@@ -831,7 +831,7 @@ static int __init exynos5440_gpiolib_register(struct platform_device *pdev,
831} 831}
832 832
833/* unregister the gpiolib interface with the gpiolib subsystem */ 833/* unregister the gpiolib interface with the gpiolib subsystem */
834static int __init exynos5440_gpiolib_unregister(struct platform_device *pdev, 834static int exynos5440_gpiolib_unregister(struct platform_device *pdev,
835 struct exynos5440_pinctrl_priv_data *priv) 835 struct exynos5440_pinctrl_priv_data *priv)
836{ 836{
837 int ret = gpiochip_remove(priv->gc); 837 int ret = gpiochip_remove(priv->gc);
diff --git a/drivers/pinctrl/pinctrl-mxs.c b/drivers/pinctrl/pinctrl-mxs.c
index dd227d21dcf2..23af9f1f9c35 100644
--- a/drivers/pinctrl/pinctrl-mxs.c
+++ b/drivers/pinctrl/pinctrl-mxs.c
@@ -146,7 +146,7 @@ free:
146static void mxs_dt_free_map(struct pinctrl_dev *pctldev, 146static void mxs_dt_free_map(struct pinctrl_dev *pctldev,
147 struct pinctrl_map *map, unsigned num_maps) 147 struct pinctrl_map *map, unsigned num_maps)
148{ 148{
149 int i; 149 u32 i;
150 150
151 for (i = 0; i < num_maps; i++) { 151 for (i = 0; i < num_maps; i++) {
152 if (map[i].type == PIN_MAP_TYPE_MUX_GROUP) 152 if (map[i].type == PIN_MAP_TYPE_MUX_GROUP)
@@ -203,7 +203,7 @@ static int mxs_pinctrl_enable(struct pinctrl_dev *pctldev, unsigned selector,
203 void __iomem *reg; 203 void __iomem *reg;
204 u8 bank, shift; 204 u8 bank, shift;
205 u16 pin; 205 u16 pin;
206 int i; 206 u32 i;
207 207
208 for (i = 0; i < g->npins; i++) { 208 for (i = 0; i < g->npins; i++) {
209 bank = PINID_TO_BANK(g->pins[i]); 209 bank = PINID_TO_BANK(g->pins[i]);
@@ -256,7 +256,7 @@ static int mxs_pinconf_group_set(struct pinctrl_dev *pctldev,
256 void __iomem *reg; 256 void __iomem *reg;
257 u8 ma, vol, pull, bank, shift; 257 u8 ma, vol, pull, bank, shift;
258 u16 pin; 258 u16 pin;
259 int i; 259 u32 i;
260 260
261 ma = CONFIG_TO_MA(config); 261 ma = CONFIG_TO_MA(config);
262 vol = CONFIG_TO_VOL(config); 262 vol = CONFIG_TO_VOL(config);
@@ -345,8 +345,7 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev,
345 const char *propname = "fsl,pinmux-ids"; 345 const char *propname = "fsl,pinmux-ids";
346 char *group; 346 char *group;
347 int length = strlen(np->name) + SUFFIX_LEN; 347 int length = strlen(np->name) + SUFFIX_LEN;
348 int i; 348 u32 val, i;
349 u32 val;
350 349
351 group = devm_kzalloc(&pdev->dev, length, GFP_KERNEL); 350 group = devm_kzalloc(&pdev->dev, length, GFP_KERNEL);
352 if (!group) 351 if (!group)
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index 1bb16ffb4e41..5767b18ebdff 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -676,7 +676,7 @@ int nmk_gpio_set_mode(int gpio, int gpio_mode)
676} 676}
677EXPORT_SYMBOL(nmk_gpio_set_mode); 677EXPORT_SYMBOL(nmk_gpio_set_mode);
678 678
679static int nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpio) 679static int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpio)
680{ 680{
681 int i; 681 int i;
682 u16 reg; 682 u16 reg;
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index f6a360b86eb6..5c32e880bcb2 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -30,7 +30,6 @@
30#define PCS_MUX_BITS_NAME "pinctrl-single,bits" 30#define PCS_MUX_BITS_NAME "pinctrl-single,bits"
31#define PCS_REG_NAME_LEN ((sizeof(unsigned long) * 2) + 1) 31#define PCS_REG_NAME_LEN ((sizeof(unsigned long) * 2) + 1)
32#define PCS_OFF_DISABLED ~0U 32#define PCS_OFF_DISABLED ~0U
33#define PCS_MAX_GPIO_VALUES 2
34 33
35/** 34/**
36 * struct pcs_pingroup - pingroups for a function 35 * struct pcs_pingroup - pingroups for a function
@@ -78,16 +77,6 @@ struct pcs_function {
78}; 77};
79 78
80/** 79/**
81 * struct pcs_gpio_range - pinctrl gpio range
82 * @range: subrange of the GPIO number space
83 * @gpio_func: gpio function value in the pinmux register
84 */
85struct pcs_gpio_range {
86 struct pinctrl_gpio_range range;
87 int gpio_func;
88};
89
90/**
91 * struct pcs_data - wrapper for data needed by pinctrl framework 80 * struct pcs_data - wrapper for data needed by pinctrl framework
92 * @pa: pindesc array 81 * @pa: pindesc array
93 * @cur: index to current element 82 * @cur: index to current element
@@ -414,26 +403,9 @@ static void pcs_disable(struct pinctrl_dev *pctldev, unsigned fselector,
414} 403}
415 404
416static int pcs_request_gpio(struct pinctrl_dev *pctldev, 405static int pcs_request_gpio(struct pinctrl_dev *pctldev,
417 struct pinctrl_gpio_range *range, unsigned pin) 406 struct pinctrl_gpio_range *range, unsigned offset)
418{ 407{
419 struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev); 408 return -ENOTSUPP;
420 struct pcs_gpio_range *gpio = NULL;
421 int end, mux_bytes;
422 unsigned data;
423
424 gpio = container_of(range, struct pcs_gpio_range, range);
425 end = range->pin_base + range->npins - 1;
426 if (pin < range->pin_base || pin > end) {
427 dev_err(pctldev->dev,
428 "pin %d isn't in the range of %d to %d\n",
429 pin, range->pin_base, end);
430 return -EINVAL;
431 }
432 mux_bytes = pcs->width / BITS_PER_BYTE;
433 data = pcs->read(pcs->base + pin * mux_bytes) & ~pcs->fmask;
434 data |= gpio->gpio_func;
435 pcs->write(data, pcs->base + pin * mux_bytes);
436 return 0;
437} 409}
438 410
439static struct pinmux_ops pcs_pinmux_ops = { 411static struct pinmux_ops pcs_pinmux_ops = {
@@ -907,49 +879,6 @@ static void pcs_free_resources(struct pcs_device *pcs)
907 879
908static struct of_device_id pcs_of_match[]; 880static struct of_device_id pcs_of_match[];
909 881
910static int pcs_add_gpio_range(struct device_node *node, struct pcs_device *pcs)
911{
912 struct pcs_gpio_range *gpio;
913 struct device_node *child;
914 struct resource r;
915 const char name[] = "pinctrl-single";
916 u32 gpiores[PCS_MAX_GPIO_VALUES];
917 int ret, i = 0, mux_bytes = 0;
918
919 for_each_child_of_node(node, child) {
920 ret = of_address_to_resource(child, 0, &r);
921 if (ret < 0)
922 continue;
923 memset(gpiores, 0, sizeof(u32) * PCS_MAX_GPIO_VALUES);
924 ret = of_property_read_u32_array(child, "pinctrl-single,gpio",
925 gpiores, PCS_MAX_GPIO_VALUES);
926 if (ret < 0)
927 continue;
928 gpio = devm_kzalloc(pcs->dev, sizeof(*gpio), GFP_KERNEL);
929 if (!gpio) {
930 dev_err(pcs->dev, "failed to allocate pcs gpio\n");
931 return -ENOMEM;
932 }
933 gpio->range.name = devm_kzalloc(pcs->dev, sizeof(name),
934 GFP_KERNEL);
935 if (!gpio->range.name) {
936 dev_err(pcs->dev, "failed to allocate range name\n");
937 return -ENOMEM;
938 }
939 memcpy((char *)gpio->range.name, name, sizeof(name));
940
941 gpio->range.id = i++;
942 gpio->range.base = gpiores[0];
943 gpio->gpio_func = gpiores[1];
944 mux_bytes = pcs->width / BITS_PER_BYTE;
945 gpio->range.pin_base = (r.start - pcs->res->start) / mux_bytes;
946 gpio->range.npins = (r.end - r.start) / mux_bytes + 1;
947
948 pinctrl_add_gpio_range(pcs->pctl, &gpio->range);
949 }
950 return 0;
951}
952
953static int pcs_probe(struct platform_device *pdev) 882static int pcs_probe(struct platform_device *pdev)
954{ 883{
955 struct device_node *np = pdev->dev.of_node; 884 struct device_node *np = pdev->dev.of_node;
@@ -1046,10 +975,6 @@ static int pcs_probe(struct platform_device *pdev)
1046 goto free; 975 goto free;
1047 } 976 }
1048 977
1049 ret = pcs_add_gpio_range(np, pcs);
1050 if (ret < 0)
1051 goto free;
1052
1053 dev_info(pcs->dev, "%i pins at pa %p size %u\n", 978 dev_info(pcs->dev, "%i pins at pa %p size %u\n",
1054 pcs->desc.npins, pcs->base, pcs->size); 979 pcs->desc.npins, pcs->base, pcs->size);
1055 980
diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
index 7481146a5b47..97c2be195efc 100644
--- a/drivers/platform/x86/ibm_rtl.c
+++ b/drivers/platform/x86/ibm_rtl.c
@@ -244,7 +244,7 @@ static int __init ibm_rtl_init(void) {
244 if (force) 244 if (force)
245 pr_warn("module loaded by force\n"); 245 pr_warn("module loaded by force\n");
246 /* first ensure that we are running on IBM HW */ 246 /* first ensure that we are running on IBM HW */
247 else if (efi_enabled || !dmi_check_system(ibm_rtl_dmi_table)) 247 else if (efi_enabled(EFI_BOOT) || !dmi_check_system(ibm_rtl_dmi_table))
248 return -ENODEV; 248 return -ENODEV;
249 249
250 /* Get the address for the Extended BIOS Data Area */ 250 /* Get the address for the Extended BIOS Data Area */
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index 71623a2ff3e8..d1f030053176 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -26,6 +26,7 @@
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/debugfs.h> 27#include <linux/debugfs.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/efi.h>
29#include <acpi/video.h> 30#include <acpi/video.h>
30 31
31/* 32/*
@@ -1544,6 +1545,9 @@ static int __init samsung_init(void)
1544 struct samsung_laptop *samsung; 1545 struct samsung_laptop *samsung;
1545 int ret; 1546 int ret;
1546 1547
1548 if (efi_enabled(EFI_BOOT))
1549 return -ENODEV;
1550
1547 quirks = &samsung_unknown; 1551 quirks = &samsung_unknown;
1548 if (!force && !dmi_check_system(samsung_dmi_table)) 1552 if (!force && !dmi_check_system(samsung_dmi_table))
1549 return -ENODEV; 1553 return -ENODEV;
diff --git a/drivers/regulator/dbx500-prcmu.c b/drivers/regulator/dbx500-prcmu.c
index 261f3d2299bc..89bd2faaef8c 100644
--- a/drivers/regulator/dbx500-prcmu.c
+++ b/drivers/regulator/dbx500-prcmu.c
@@ -14,6 +14,7 @@
14#include <linux/debugfs.h> 14#include <linux/debugfs.h>
15#include <linux/seq_file.h> 15#include <linux/seq_file.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/module.h>
17 18
18#include "dbx500-prcmu.h" 19#include "dbx500-prcmu.h"
19 20
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
index b15d711bc8c6..9019d0e7ecb6 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -728,7 +728,7 @@ static int tps80031_regulator_probe(struct platform_device *pdev)
728 } 728 }
729 } 729 }
730 rdev = regulator_register(&ri->rinfo->desc, &config); 730 rdev = regulator_register(&ri->rinfo->desc, &config);
731 if (IS_ERR_OR_NULL(rdev)) { 731 if (IS_ERR(rdev)) {
732 dev_err(&pdev->dev, 732 dev_err(&pdev->dev,
733 "register regulator failed %s\n", 733 "register regulator failed %s\n",
734 ri->rinfo->desc.name); 734 ri->rinfo->desc.name);
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 923a9da9c829..f11f746f7a35 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -269,6 +269,16 @@ config RTC_DRV_X1205
269 This driver can also be built as a module. If so, the module 269 This driver can also be built as a module. If so, the module
270 will be called rtc-x1205. 270 will be called rtc-x1205.
271 271
272config RTC_DRV_PALMAS
273 tristate "TI Palmas RTC driver"
274 depends on MFD_PALMAS
275 help
276 If you say yes here you get support for the RTC of TI PALMA series PMIC
277 chips.
278
279 This driver can also be built as a module. If so, the module
280 will be called rtc-palma.
281
272config RTC_DRV_PCF8523 282config RTC_DRV_PCF8523
273 tristate "NXP PCF8523" 283 tristate "NXP PCF8523"
274 help 284 help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 4418ef3f9ecc..3b66c75f6c76 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o
76obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o 76obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o
77obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o 77obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o
78obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o 78obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
79obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o
79obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o 80obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o
80obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o 81obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o
81obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 82obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
diff --git a/drivers/rtc/rtc-palmas.c b/drivers/rtc/rtc-palmas.c
new file mode 100644
index 000000000000..59c42986254e
--- /dev/null
+++ b/drivers/rtc/rtc-palmas.c
@@ -0,0 +1,339 @@
1/*
2 * rtc-palmas.c -- Palmas Real Time Clock driver.
3
4 * RTC driver for TI Palma series devices like TPS65913,
5 * TPS65914 power management IC.
6 *
7 * Copyright (c) 2012, NVIDIA Corporation.
8 *
9 * Author: Laxman Dewangan <ldewangan@nvidia.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation version 2.
14 *
15 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
16 * whether express or implied; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307, USA
24 */
25
26#include <linux/bcd.h>
27#include <linux/errno.h>
28#include <linux/init.h>
29#include <linux/interrupt.h>
30#include <linux/kernel.h>
31#include <linux/mfd/palmas.h>
32#include <linux/module.h>
33#include <linux/rtc.h>
34#include <linux/types.h>
35#include <linux/platform_device.h>
36#include <linux/pm.h>
37
38struct palmas_rtc {
39 struct rtc_device *rtc;
40 struct device *dev;
41 unsigned int irq;
42};
43
44/* Total number of RTC registers needed to set time*/
45#define PALMAS_NUM_TIME_REGS (PALMAS_YEARS_REG - PALMAS_SECONDS_REG + 1)
46
47static int palmas_rtc_read_time(struct device *dev, struct rtc_time *tm)
48{
49 unsigned char rtc_data[PALMAS_NUM_TIME_REGS];
50 struct palmas *palmas = dev_get_drvdata(dev->parent);
51 int ret;
52
53 /* Copy RTC counting registers to static registers or latches */
54 ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG,
55 PALMAS_RTC_CTRL_REG_GET_TIME, PALMAS_RTC_CTRL_REG_GET_TIME);
56 if (ret < 0) {
57 dev_err(dev, "RTC CTRL reg update failed, err: %d\n", ret);
58 return ret;
59 }
60
61 ret = palmas_bulk_read(palmas, PALMAS_RTC_BASE, PALMAS_SECONDS_REG,
62 rtc_data, PALMAS_NUM_TIME_REGS);
63 if (ret < 0) {
64 dev_err(dev, "RTC_SECONDS reg read failed, err = %d\n", ret);
65 return ret;
66 }
67
68 tm->tm_sec = bcd2bin(rtc_data[0]);
69 tm->tm_min = bcd2bin(rtc_data[1]);
70 tm->tm_hour = bcd2bin(rtc_data[2]);
71 tm->tm_mday = bcd2bin(rtc_data[3]);
72 tm->tm_mon = bcd2bin(rtc_data[4]) - 1;
73 tm->tm_year = bcd2bin(rtc_data[5]) + 100;
74
75 return ret;
76}
77
78static int palmas_rtc_set_time(struct device *dev, struct rtc_time *tm)
79{
80 unsigned char rtc_data[PALMAS_NUM_TIME_REGS];
81 struct palmas *palmas = dev_get_drvdata(dev->parent);
82 int ret;
83
84 rtc_data[0] = bin2bcd(tm->tm_sec);
85 rtc_data[1] = bin2bcd(tm->tm_min);
86 rtc_data[2] = bin2bcd(tm->tm_hour);
87 rtc_data[3] = bin2bcd(tm->tm_mday);
88 rtc_data[4] = bin2bcd(tm->tm_mon + 1);
89 rtc_data[5] = bin2bcd(tm->tm_year - 100);
90
91 /* Stop RTC while updating the RTC time registers */
92 ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG,
93 PALMAS_RTC_CTRL_REG_STOP_RTC, 0);
94 if (ret < 0) {
95 dev_err(dev, "RTC stop failed, err = %d\n", ret);
96 return ret;
97 }
98
99 ret = palmas_bulk_write(palmas, PALMAS_RTC_BASE, PALMAS_SECONDS_REG,
100 rtc_data, PALMAS_NUM_TIME_REGS);
101 if (ret < 0) {
102 dev_err(dev, "RTC_SECONDS reg write failed, err = %d\n", ret);
103 return ret;
104 }
105
106 /* Start back RTC */
107 ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG,
108 PALMAS_RTC_CTRL_REG_STOP_RTC, PALMAS_RTC_CTRL_REG_STOP_RTC);
109 if (ret < 0)
110 dev_err(dev, "RTC start failed, err = %d\n", ret);
111 return ret;
112}
113
114static int palmas_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
115{
116 struct palmas *palmas = dev_get_drvdata(dev->parent);
117 u8 val;
118
119 val = enabled ? PALMAS_RTC_INTERRUPTS_REG_IT_ALARM : 0;
120 return palmas_write(palmas, PALMAS_RTC_BASE,
121 PALMAS_RTC_INTERRUPTS_REG, val);
122}
123
124static int palmas_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
125{
126 unsigned char alarm_data[PALMAS_NUM_TIME_REGS];
127 u32 int_val;
128 struct palmas *palmas = dev_get_drvdata(dev->parent);
129 int ret;
130
131 ret = palmas_bulk_read(palmas, PALMAS_RTC_BASE,
132 PALMAS_ALARM_SECONDS_REG,
133 alarm_data, PALMAS_NUM_TIME_REGS);
134 if (ret < 0) {
135 dev_err(dev, "RTC_ALARM_SECONDS read failed, err = %d\n", ret);
136 return ret;
137 }
138
139 alm->time.tm_sec = bcd2bin(alarm_data[0]);
140 alm->time.tm_min = bcd2bin(alarm_data[1]);
141 alm->time.tm_hour = bcd2bin(alarm_data[2]);
142 alm->time.tm_mday = bcd2bin(alarm_data[3]);
143 alm->time.tm_mon = bcd2bin(alarm_data[4]) - 1;
144 alm->time.tm_year = bcd2bin(alarm_data[5]) + 100;
145
146 ret = palmas_read(palmas, PALMAS_RTC_BASE, PALMAS_RTC_INTERRUPTS_REG,
147 &int_val);
148 if (ret < 0) {
149 dev_err(dev, "RTC_INTERRUPTS reg read failed, err = %d\n", ret);
150 return ret;
151 }
152
153 if (int_val & PALMAS_RTC_INTERRUPTS_REG_IT_ALARM)
154 alm->enabled = 1;
155 return ret;
156}
157
158static int palmas_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
159{
160 unsigned char alarm_data[PALMAS_NUM_TIME_REGS];
161 struct palmas *palmas = dev_get_drvdata(dev->parent);
162 int ret;
163
164 ret = palmas_rtc_alarm_irq_enable(dev, 0);
165 if (ret < 0) {
166 dev_err(dev, "Disable RTC alarm failed\n");
167 return ret;
168 }
169
170 alarm_data[0] = bin2bcd(alm->time.tm_sec);
171 alarm_data[1] = bin2bcd(alm->time.tm_min);
172 alarm_data[2] = bin2bcd(alm->time.tm_hour);
173 alarm_data[3] = bin2bcd(alm->time.tm_mday);
174 alarm_data[4] = bin2bcd(alm->time.tm_mon + 1);
175 alarm_data[5] = bin2bcd(alm->time.tm_year - 100);
176
177 ret = palmas_bulk_write(palmas, PALMAS_RTC_BASE,
178 PALMAS_ALARM_SECONDS_REG, alarm_data, PALMAS_NUM_TIME_REGS);
179 if (ret < 0) {
180 dev_err(dev, "ALARM_SECONDS_REG write failed, err = %d\n", ret);
181 return ret;
182 }
183
184 if (alm->enabled)
185 ret = palmas_rtc_alarm_irq_enable(dev, 1);
186 return ret;
187}
188
189static int palmas_clear_interrupts(struct device *dev)
190{
191 struct palmas *palmas = dev_get_drvdata(dev->parent);
192 unsigned int rtc_reg;
193 int ret;
194
195 ret = palmas_read(palmas, PALMAS_RTC_BASE, PALMAS_RTC_STATUS_REG,
196 &rtc_reg);
197 if (ret < 0) {
198 dev_err(dev, "RTC_STATUS read failed, err = %d\n", ret);
199 return ret;
200 }
201
202 ret = palmas_write(palmas, PALMAS_RTC_BASE, PALMAS_RTC_STATUS_REG,
203 rtc_reg);
204 if (ret < 0) {
205 dev_err(dev, "RTC_STATUS write failed, err = %d\n", ret);
206 return ret;
207 }
208 return 0;
209}
210
211static irqreturn_t palmas_rtc_interrupt(int irq, void *context)
212{
213 struct palmas_rtc *palmas_rtc = context;
214 struct device *dev = palmas_rtc->dev;
215 int ret;
216
217 ret = palmas_clear_interrupts(dev);
218 if (ret < 0) {
219 dev_err(dev, "RTC interrupt clear failed, err = %d\n", ret);
220 return IRQ_NONE;
221 }
222
223 rtc_update_irq(palmas_rtc->rtc, 1, RTC_IRQF | RTC_AF);
224 return IRQ_HANDLED;
225}
226
227static struct rtc_class_ops palmas_rtc_ops = {
228 .read_time = palmas_rtc_read_time,
229 .set_time = palmas_rtc_set_time,
230 .read_alarm = palmas_rtc_read_alarm,
231 .set_alarm = palmas_rtc_set_alarm,
232 .alarm_irq_enable = palmas_rtc_alarm_irq_enable,
233};
234
235static int palmas_rtc_probe(struct platform_device *pdev)
236{
237 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
238 struct palmas_rtc *palmas_rtc = NULL;
239 int ret;
240
241 palmas_rtc = devm_kzalloc(&pdev->dev, sizeof(struct palmas_rtc),
242 GFP_KERNEL);
243 if (!palmas_rtc)
244 return -ENOMEM;
245
246 /* Clear pending interrupts */
247 ret = palmas_clear_interrupts(&pdev->dev);
248 if (ret < 0) {
249 dev_err(&pdev->dev, "clear RTC int failed, err = %d\n", ret);
250 return ret;
251 }
252
253 palmas_rtc->dev = &pdev->dev;
254 platform_set_drvdata(pdev, palmas_rtc);
255
256 /* Start RTC */
257 ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG,
258 PALMAS_RTC_CTRL_REG_STOP_RTC,
259 PALMAS_RTC_CTRL_REG_STOP_RTC);
260 if (ret < 0) {
261 dev_err(&pdev->dev, "RTC_CTRL write failed, err = %d\n", ret);
262 return ret;
263 }
264
265 palmas_rtc->irq = platform_get_irq(pdev, 0);
266
267 palmas_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
268 &palmas_rtc_ops, THIS_MODULE);
269 if (IS_ERR(palmas_rtc->rtc)) {
270 ret = PTR_ERR(palmas_rtc->rtc);
271 dev_err(&pdev->dev, "RTC register failed, err = %d\n", ret);
272 return ret;
273 }
274
275 ret = request_threaded_irq(palmas_rtc->irq, NULL,
276 palmas_rtc_interrupt,
277 IRQF_TRIGGER_LOW | IRQF_ONESHOT |
278 IRQF_EARLY_RESUME,
279 dev_name(&pdev->dev), palmas_rtc);
280 if (ret < 0) {
281 dev_err(&pdev->dev, "IRQ request failed, err = %d\n", ret);
282 rtc_device_unregister(palmas_rtc->rtc);
283 return ret;
284 }
285
286 device_set_wakeup_capable(&pdev->dev, 1);
287 return 0;
288}
289
290static int palmas_rtc_remove(struct platform_device *pdev)
291{
292 struct palmas_rtc *palmas_rtc = platform_get_drvdata(pdev);
293
294 palmas_rtc_alarm_irq_enable(&pdev->dev, 0);
295 free_irq(palmas_rtc->irq, palmas_rtc);
296 rtc_device_unregister(palmas_rtc->rtc);
297 return 0;
298}
299
300#ifdef CONFIG_PM_SLEEP
301static int palmas_rtc_suspend(struct device *dev)
302{
303 struct palmas_rtc *palmas_rtc = dev_get_drvdata(dev);
304
305 if (device_may_wakeup(dev))
306 enable_irq_wake(palmas_rtc->irq);
307 return 0;
308}
309
310static int palmas_rtc_resume(struct device *dev)
311{
312 struct palmas_rtc *palmas_rtc = dev_get_drvdata(dev);
313
314 if (device_may_wakeup(dev))
315 disable_irq_wake(palmas_rtc->irq);
316 return 0;
317}
318#endif
319
320static const struct dev_pm_ops palmas_rtc_pm_ops = {
321 SET_SYSTEM_SLEEP_PM_OPS(palmas_rtc_suspend, palmas_rtc_resume)
322};
323
324static struct platform_driver palmas_rtc_driver = {
325 .probe = palmas_rtc_probe,
326 .remove = palmas_rtc_remove,
327 .driver = {
328 .owner = THIS_MODULE,
329 .name = "palmas-rtc",
330 .pm = &palmas_rtc_pm_ops,
331 },
332};
333
334module_platform_driver(palmas_rtc_driver);
335
336MODULE_ALIAS("platform:palmas_rtc");
337MODULE_DESCRIPTION("TI PALMAS series RTC driver");
338MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
339MODULE_LICENSE("GPL v2");
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index d73fdcfeb45a..2839baa82a5a 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -633,7 +633,7 @@ static int isci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
633 return -ENOMEM; 633 return -ENOMEM;
634 pci_set_drvdata(pdev, pci_info); 634 pci_set_drvdata(pdev, pci_info);
635 635
636 if (efi_enabled) 636 if (efi_enabled(EFI_RUNTIME_SERVICES))
637 orom = isci_get_efi_var(pdev); 637 orom = isci_get_efi_var(pdev);
638 638
639 if (!orom) 639 if (!orom)
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index 2c9bce050aa9..5ca11b066b7e 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = {
101 .get_brightness = max8925_backlight_get_brightness, 101 .get_brightness = max8925_backlight_get_brightness,
102}; 102};
103 103
104#ifdef CONFIG_OF
105static int max8925_backlight_dt_init(struct platform_device *pdev,
106 struct max8925_backlight_pdata *pdata)
107{
108 struct device_node *nproot = pdev->dev.parent->of_node, *np;
109 int dual_string;
110
111 if (!nproot)
112 return -ENODEV;
113 np = of_find_node_by_name(nproot, "backlight");
114 if (!np) {
115 dev_err(&pdev->dev, "failed to find backlight node\n");
116 return -ENODEV;
117 }
118
119 of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string);
120 pdata->dual_string = dual_string;
121 return 0;
122}
123#else
124#define max8925_backlight_dt_init(x, y) (-1)
125#endif
126
104static int max8925_backlight_probe(struct platform_device *pdev) 127static int max8925_backlight_probe(struct platform_device *pdev)
105{ 128{
106 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 129 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -147,6 +170,13 @@ static int max8925_backlight_probe(struct platform_device *pdev)
147 platform_set_drvdata(pdev, bl); 170 platform_set_drvdata(pdev, bl);
148 171
149 value = 0; 172 value = 0;
173 if (pdev->dev.parent->of_node && !pdata) {
174 pdata = devm_kzalloc(&pdev->dev,
175 sizeof(struct max8925_backlight_pdata),
176 GFP_KERNEL);
177 max8925_backlight_dt_init(pdev, pdata);
178 }
179
150 if (pdata) { 180 if (pdata) {
151 if (pdata->lxw_scl) 181 if (pdata->lxw_scl)
152 value |= (1 << 7); 182 value |= (1 << 7);
@@ -158,7 +188,6 @@ static int max8925_backlight_probe(struct platform_device *pdev)
158 ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value); 188 ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value);
159 if (ret < 0) 189 if (ret < 0)
160 goto out_brt; 190 goto out_brt;
161
162 backlight_update_status(bl); 191 backlight_update_status(bl);
163 return 0; 192 return 0;
164out_brt: 193out_brt:
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 7f809fd4a57f..26e1fdbddf69 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -364,6 +364,18 @@ config IMX2_WDT
364 To compile this driver as a module, choose M here: the 364 To compile this driver as a module, choose M here: the
365 module will be called imx2_wdt. 365 module will be called imx2_wdt.
366 366
367config UX500_WATCHDOG
368 tristate "ST-Ericsson Ux500 watchdog"
369 depends on MFD_DB8500_PRCMU
370 select WATCHDOG_CORE
371 default y
372 help
373 Say Y here to include Watchdog timer support for the watchdog
374 existing in the prcmu of ST-Ericsson Ux500 series platforms.
375
376 To compile this driver as a module, choose M here: the
377 module will be called ux500_wdt.
378
367# AVR32 Architecture 379# AVR32 Architecture
368 380
369config AT32AP700X_WDT 381config AT32AP700X_WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 97bbdb3a4648..bec86ee6e9e3 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
52obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o 52obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
53obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o 53obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
54obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o 54obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
55obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o
55 56
56# AVR32 Architecture 57# AVR32 Architecture
57obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o 58obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/watchdog/ux500_wdt.c b/drivers/watchdog/ux500_wdt.c
new file mode 100644
index 000000000000..a614d84121c3
--- /dev/null
+++ b/drivers/watchdog/ux500_wdt.c
@@ -0,0 +1,171 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2011-2013
3 *
4 * License Terms: GNU General Public License v2
5 *
6 * Author: Mathieu Poirier <mathieu.poirier@linaro.org> for ST-Ericsson
7 * Author: Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson
8 */
9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/moduleparam.h>
15#include <linux/miscdevice.h>
16#include <linux/err.h>
17#include <linux/uaccess.h>
18#include <linux/watchdog.h>
19#include <linux/platform_device.h>
20#include <linux/platform_data/ux500_wdt.h>
21
22#include <linux/mfd/dbx500-prcmu.h>
23
24#define WATCHDOG_TIMEOUT 600 /* 10 minutes */
25
26#define WATCHDOG_MIN 0
27#define WATCHDOG_MAX28 268435 /* 28 bit resolution in ms == 268435.455 s */
28#define WATCHDOG_MAX32 4294967 /* 32 bit resolution in ms == 4294967.295 s */
29
30static unsigned int timeout = WATCHDOG_TIMEOUT;
31module_param(timeout, uint, 0);
32MODULE_PARM_DESC(timeout,
33 "Watchdog timeout in seconds. default="
34 __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
35
36static bool nowayout = WATCHDOG_NOWAYOUT;
37module_param(nowayout, bool, 0);
38MODULE_PARM_DESC(nowayout,
39 "Watchdog cannot be stopped once started (default="
40 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
41
42static int ux500_wdt_start(struct watchdog_device *wdd)
43{
44 return prcmu_enable_a9wdog(PRCMU_WDOG_ALL);
45}
46
47static int ux500_wdt_stop(struct watchdog_device *wdd)
48{
49 return prcmu_disable_a9wdog(PRCMU_WDOG_ALL);
50}
51
52static int ux500_wdt_keepalive(struct watchdog_device *wdd)
53{
54 return prcmu_kick_a9wdog(PRCMU_WDOG_ALL);
55}
56
57static int ux500_wdt_set_timeout(struct watchdog_device *wdd,
58 unsigned int timeout)
59{
60 ux500_wdt_stop(wdd);
61 prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000);
62 ux500_wdt_start(wdd);
63
64 return 0;
65}
66
67static const struct watchdog_info ux500_wdt_info = {
68 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
69 .identity = "Ux500 WDT",
70 .firmware_version = 1,
71};
72
73static const struct watchdog_ops ux500_wdt_ops = {
74 .owner = THIS_MODULE,
75 .start = ux500_wdt_start,
76 .stop = ux500_wdt_stop,
77 .ping = ux500_wdt_keepalive,
78 .set_timeout = ux500_wdt_set_timeout,
79};
80
81static struct watchdog_device ux500_wdt = {
82 .info = &ux500_wdt_info,
83 .ops = &ux500_wdt_ops,
84 .min_timeout = WATCHDOG_MIN,
85 .max_timeout = WATCHDOG_MAX32,
86};
87
88static int ux500_wdt_probe(struct platform_device *pdev)
89{
90 int ret;
91 struct ux500_wdt_data *pdata = pdev->dev.platform_data;
92
93 if (pdata) {
94 if (pdata->timeout > 0)
95 timeout = pdata->timeout;
96 if (pdata->has_28_bits_resolution)
97 ux500_wdt.max_timeout = WATCHDOG_MAX28;
98 }
99
100 watchdog_set_nowayout(&ux500_wdt, nowayout);
101
102 /* disable auto off on sleep */
103 prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false);
104
105 /* set HW initial value */
106 prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000);
107
108 ret = watchdog_register_device(&ux500_wdt);
109 if (ret)
110 return ret;
111
112 dev_info(&pdev->dev, "initialized\n");
113
114 return 0;
115}
116
117static int ux500_wdt_remove(struct platform_device *dev)
118{
119 watchdog_unregister_device(&ux500_wdt);
120
121 return 0;
122}
123
124#ifdef CONFIG_PM
125static int ux500_wdt_suspend(struct platform_device *pdev,
126 pm_message_t state)
127{
128 if (watchdog_active(&ux500_wdt)) {
129 ux500_wdt_stop(&ux500_wdt);
130 prcmu_config_a9wdog(PRCMU_WDOG_CPU1, true);
131
132 prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000);
133 ux500_wdt_start(&ux500_wdt);
134 }
135 return 0;
136}
137
138static int ux500_wdt_resume(struct platform_device *pdev)
139{
140 if (watchdog_active(&ux500_wdt)) {
141 ux500_wdt_stop(&ux500_wdt);
142 prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false);
143
144 prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000);
145 ux500_wdt_start(&ux500_wdt);
146 }
147 return 0;
148}
149#else
150#define ux500_wdt_suspend NULL
151#define ux500_wdt_resume NULL
152#endif
153
154static struct platform_driver ux500_wdt_driver = {
155 .probe = ux500_wdt_probe,
156 .remove = ux500_wdt_remove,
157 .suspend = ux500_wdt_suspend,
158 .resume = ux500_wdt_resume,
159 .driver = {
160 .owner = THIS_MODULE,
161 .name = "ux500_wdt",
162 },
163};
164
165module_platform_driver(ux500_wdt_driver);
166
167MODULE_AUTHOR("Jonas Aaberg <jonas.aberg@stericsson.com>");
168MODULE_DESCRIPTION("Ux500 Watchdog Driver");
169MODULE_LICENSE("GPL");
170MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
171MODULE_ALIAS("platform:ux500_wdt");