Commit 89027fea authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mauro Carvalho Chehab

media: atomisp: Unify pdev to be pointer to struct pci_device

Unify pdev to be pointer to struct pci_device.

While here, reindent some (touched) lines for better readability.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 1cfc8593
...@@ -360,39 +360,39 @@ static void clear_isp_irq(enum hrt_isp_css_irq irq) ...@@ -360,39 +360,39 @@ static void clear_isp_irq(enum hrt_isp_css_irq irq)
void atomisp_msi_irq_init(struct atomisp_device *isp) void atomisp_msi_irq_init(struct atomisp_device *isp)
{ {
struct pci_dev *dev = to_pci_dev(isp->dev); struct pci_dev *pdev = to_pci_dev(isp->dev);
u32 msg32; u32 msg32;
u16 msg16; u16 msg16;
pci_read_config_dword(dev, PCI_MSI_CAPID, &msg32); pci_read_config_dword(pdev, PCI_MSI_CAPID, &msg32);
msg32 |= 1 << MSI_ENABLE_BIT; msg32 |= 1 << MSI_ENABLE_BIT;
pci_write_config_dword(dev, PCI_MSI_CAPID, msg32); pci_write_config_dword(pdev, PCI_MSI_CAPID, msg32);
msg32 = (1 << INTR_IER) | (1 << INTR_IIR); msg32 = (1 << INTR_IER) | (1 << INTR_IIR);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, msg32); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg32);
pci_read_config_word(dev, PCI_COMMAND, &msg16); pci_read_config_word(pdev, PCI_COMMAND, &msg16);
msg16 |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | msg16 |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
PCI_COMMAND_INTX_DISABLE); PCI_COMMAND_INTX_DISABLE);
pci_write_config_word(dev, PCI_COMMAND, msg16); pci_write_config_word(pdev, PCI_COMMAND, msg16);
} }
void atomisp_msi_irq_uninit(struct atomisp_device *isp) void atomisp_msi_irq_uninit(struct atomisp_device *isp)
{ {
struct pci_dev *dev = to_pci_dev(isp->dev); struct pci_dev *pdev = to_pci_dev(isp->dev);
u32 msg32; u32 msg32;
u16 msg16; u16 msg16;
pci_read_config_dword(dev, PCI_MSI_CAPID, &msg32); pci_read_config_dword(pdev, PCI_MSI_CAPID, &msg32);
msg32 &= ~(1 << MSI_ENABLE_BIT); msg32 &= ~(1 << MSI_ENABLE_BIT);
pci_write_config_dword(dev, PCI_MSI_CAPID, msg32); pci_write_config_dword(pdev, PCI_MSI_CAPID, msg32);
msg32 = 0x0; msg32 = 0x0;
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, msg32); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg32);
pci_read_config_word(dev, PCI_COMMAND, &msg16); pci_read_config_word(pdev, PCI_COMMAND, &msg16);
msg16 &= ~(PCI_COMMAND_MASTER); msg16 &= ~(PCI_COMMAND_MASTER);
pci_write_config_word(dev, PCI_COMMAND, msg16); pci_write_config_word(pdev, PCI_COMMAND, msg16);
} }
static void atomisp_sof_event(struct atomisp_sub_device *asd) static void atomisp_sof_event(struct atomisp_sub_device *asd)
......
...@@ -1323,10 +1323,10 @@ EXPORT_SYMBOL_GPL(camera_sensor_csi); ...@@ -1323,10 +1323,10 @@ EXPORT_SYMBOL_GPL(camera_sensor_csi);
* trying. The driver itself does direct calls to the PUNIT to manage * trying. The driver itself does direct calls to the PUNIT to manage
* ISP power. * ISP power.
*/ */
static void isp_pm_cap_fixup(struct pci_dev *dev) static void isp_pm_cap_fixup(struct pci_dev *pdev)
{ {
dev_info(&dev->dev, "Disabling PCI power management on camera ISP\n"); dev_info(&pdev->dev, "Disabling PCI power management on camera ISP\n");
dev->pm_cap = 0; pdev->pm_cap = 0;
} }
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0f38, isp_pm_cap_fixup); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0f38, isp_pm_cap_fixup);
......
...@@ -512,30 +512,27 @@ void atomisp_acc_unregister(struct atomisp_acc_pipe *video) ...@@ -512,30 +512,27 @@ void atomisp_acc_unregister(struct atomisp_acc_pipe *video)
static int atomisp_save_iunit_reg(struct atomisp_device *isp) static int atomisp_save_iunit_reg(struct atomisp_device *isp)
{ {
struct pci_dev *dev = to_pci_dev(isp->dev); struct pci_dev *pdev = to_pci_dev(isp->dev);
dev_dbg(isp->dev, "%s\n", __func__); dev_dbg(isp->dev, "%s\n", __func__);
pci_read_config_word(dev, PCI_COMMAND, &isp->saved_regs.pcicmdsts); pci_read_config_word(pdev, PCI_COMMAND, &isp->saved_regs.pcicmdsts);
/* isp->saved_regs.ispmmadr is set from the atomisp_pci_probe() */ /* isp->saved_regs.ispmmadr is set from the atomisp_pci_probe() */
pci_read_config_dword(dev, PCI_MSI_CAPID, &isp->saved_regs.msicap); pci_read_config_dword(pdev, PCI_MSI_CAPID, &isp->saved_regs.msicap);
pci_read_config_dword(dev, PCI_MSI_ADDR, &isp->saved_regs.msi_addr); pci_read_config_dword(pdev, PCI_MSI_ADDR, &isp->saved_regs.msi_addr);
pci_read_config_word(dev, PCI_MSI_DATA, &isp->saved_regs.msi_data); pci_read_config_word(pdev, PCI_MSI_DATA, &isp->saved_regs.msi_data);
pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &isp->saved_regs.intr); pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &isp->saved_regs.intr);
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &isp->saved_regs.interrupt_control);
&isp->saved_regs.interrupt_control);
pci_read_config_dword(pdev, MRFLD_PCI_PMCS, &isp->saved_regs.pmcs);
pci_read_config_dword(dev, MRFLD_PCI_PMCS,
&isp->saved_regs.pmcs);
/* Ensure read/write combining is enabled. */ /* Ensure read/write combining is enabled. */
pci_read_config_dword(dev, PCI_I_CONTROL, pci_read_config_dword(pdev, PCI_I_CONTROL, &isp->saved_regs.i_control);
&isp->saved_regs.i_control);
isp->saved_regs.i_control |= isp->saved_regs.i_control |=
MRFLD_PCI_I_CONTROL_ENABLE_READ_COMBINING | MRFLD_PCI_I_CONTROL_ENABLE_READ_COMBINING |
MRFLD_PCI_I_CONTROL_ENABLE_WRITE_COMBINING; MRFLD_PCI_I_CONTROL_ENABLE_WRITE_COMBINING;
pci_read_config_dword(dev, MRFLD_PCI_CSI_ACCESS_CTRL_VIOL, pci_read_config_dword(pdev, MRFLD_PCI_CSI_ACCESS_CTRL_VIOL,
&isp->saved_regs.csi_access_viol); &isp->saved_regs.csi_access_viol);
pci_read_config_dword(dev, MRFLD_PCI_CSI_RCOMP_CONTROL, pci_read_config_dword(pdev, MRFLD_PCI_CSI_RCOMP_CONTROL,
&isp->saved_regs.csi_rcomp_config); &isp->saved_regs.csi_rcomp_config);
/* /*
* Hardware bugs require setting CSI_HS_OVR_CLK_GATE_ON_UPDATE. * Hardware bugs require setting CSI_HS_OVR_CLK_GATE_ON_UPDATE.
...@@ -545,65 +542,58 @@ static int atomisp_save_iunit_reg(struct atomisp_device *isp) ...@@ -545,65 +542,58 @@ static int atomisp_save_iunit_reg(struct atomisp_device *isp)
* is missed, and IUNIT can hang. * is missed, and IUNIT can hang.
* For both issues, setting this bit is a workaround. * For both issues, setting this bit is a workaround.
*/ */
isp->saved_regs.csi_rcomp_config |= isp->saved_regs.csi_rcomp_config |= MRFLD_PCI_CSI_HS_OVR_CLK_GATE_ON_UPDATE;
MRFLD_PCI_CSI_HS_OVR_CLK_GATE_ON_UPDATE; pci_read_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL,
pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL,
&isp->saved_regs.csi_afe_dly); &isp->saved_regs.csi_afe_dly);
pci_read_config_dword(dev, MRFLD_PCI_CSI_CONTROL, pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL,
&isp->saved_regs.csi_control); &isp->saved_regs.csi_control);
if (isp->media_dev.hw_revision >= if (isp->media_dev.hw_revision >=
(ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT)) (ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT))
isp->saved_regs.csi_control |= isp->saved_regs.csi_control |= MRFLD_PCI_CSI_CONTROL_PARPATHEN;
MRFLD_PCI_CSI_CONTROL_PARPATHEN;
/* /*
* On CHT CSI_READY bit should be enabled before stream on * On CHT CSI_READY bit should be enabled before stream on
*/ */
if (IS_CHT && (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 << if (IS_CHT && (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0))) ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)))
isp->saved_regs.csi_control |= isp->saved_regs.csi_control |= MRFLD_PCI_CSI_CONTROL_CSI_READY;
MRFLD_PCI_CSI_CONTROL_CSI_READY; pci_read_config_dword(pdev, MRFLD_PCI_CSI_AFE_RCOMP_CONTROL,
pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_RCOMP_CONTROL,
&isp->saved_regs.csi_afe_rcomp_config); &isp->saved_regs.csi_afe_rcomp_config);
pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_HS_CONTROL, pci_read_config_dword(pdev, MRFLD_PCI_CSI_AFE_HS_CONTROL,
&isp->saved_regs.csi_afe_hs_control); &isp->saved_regs.csi_afe_hs_control);
pci_read_config_dword(dev, MRFLD_PCI_CSI_DEADLINE_CONTROL, pci_read_config_dword(pdev, MRFLD_PCI_CSI_DEADLINE_CONTROL,
&isp->saved_regs.csi_deadline_control); &isp->saved_regs.csi_deadline_control);
return 0; return 0;
} }
static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp) static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp)
{ {
struct pci_dev *dev = to_pci_dev(isp->dev); struct pci_dev *pdev = to_pci_dev(isp->dev);
dev_dbg(isp->dev, "%s\n", __func__); dev_dbg(isp->dev, "%s\n", __func__);
pci_write_config_word(dev, PCI_COMMAND, isp->saved_regs.pcicmdsts); pci_write_config_word(pdev, PCI_COMMAND, isp->saved_regs.pcicmdsts);
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, isp->saved_regs.ispmmadr);
isp->saved_regs.ispmmadr); pci_write_config_dword(pdev, PCI_MSI_CAPID, isp->saved_regs.msicap);
pci_write_config_dword(dev, PCI_MSI_CAPID, isp->saved_regs.msicap); pci_write_config_dword(pdev, PCI_MSI_ADDR, isp->saved_regs.msi_addr);
pci_write_config_dword(dev, PCI_MSI_ADDR, isp->saved_regs.msi_addr); pci_write_config_word(pdev, PCI_MSI_DATA, isp->saved_regs.msi_data);
pci_write_config_word(dev, PCI_MSI_DATA, isp->saved_regs.msi_data); pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, isp->saved_regs.intr);
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, isp->saved_regs.intr); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, isp->saved_regs.interrupt_control);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, pci_write_config_dword(pdev, PCI_I_CONTROL, isp->saved_regs.i_control);
isp->saved_regs.interrupt_control);
pci_write_config_dword(dev, PCI_I_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_PMCS, isp->saved_regs.pmcs);
isp->saved_regs.i_control); pci_write_config_dword(pdev, MRFLD_PCI_CSI_ACCESS_CTRL_VIOL,
pci_write_config_dword(dev, MRFLD_PCI_PMCS,
isp->saved_regs.pmcs);
pci_write_config_dword(dev, MRFLD_PCI_CSI_ACCESS_CTRL_VIOL,
isp->saved_regs.csi_access_viol); isp->saved_regs.csi_access_viol);
pci_write_config_dword(dev, MRFLD_PCI_CSI_RCOMP_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_CSI_RCOMP_CONTROL,
isp->saved_regs.csi_rcomp_config); isp->saved_regs.csi_rcomp_config);
pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL,
isp->saved_regs.csi_afe_dly); isp->saved_regs.csi_afe_dly);
pci_write_config_dword(dev, MRFLD_PCI_CSI_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL,
isp->saved_regs.csi_control); isp->saved_regs.csi_control);
pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_RCOMP_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_CSI_AFE_RCOMP_CONTROL,
isp->saved_regs.csi_afe_rcomp_config); isp->saved_regs.csi_afe_rcomp_config);
pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_HS_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_CSI_AFE_HS_CONTROL,
isp->saved_regs.csi_afe_hs_control); isp->saved_regs.csi_afe_hs_control);
pci_write_config_dword(dev, MRFLD_PCI_CSI_DEADLINE_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_CSI_DEADLINE_CONTROL,
isp->saved_regs.csi_deadline_control); isp->saved_regs.csi_deadline_control);
/* /*
...@@ -619,7 +609,7 @@ static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp) ...@@ -619,7 +609,7 @@ static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp)
static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp) static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
{ {
struct pci_dev *dev = to_pci_dev(isp->dev); struct pci_dev *pdev = to_pci_dev(isp->dev);
u32 irq; u32 irq;
unsigned long flags; unsigned long flags;
...@@ -635,11 +625,11 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp) ...@@ -635,11 +625,11 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
* So, here we need to check if there is any pending * So, here we need to check if there is any pending
* IRQ, if so, waiting for it to be served * IRQ, if so, waiting for it to be served
*/ */
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq); pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
irq = irq & 1 << INTR_IIR; irq = irq & 1 << INTR_IIR;
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, irq);
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq); pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
if (!(irq & (1 << INTR_IIR))) if (!(irq & (1 << INTR_IIR)))
goto done; goto done;
...@@ -652,11 +642,11 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp) ...@@ -652,11 +642,11 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
spin_unlock_irqrestore(&isp->lock, flags); spin_unlock_irqrestore(&isp->lock, flags);
return -EAGAIN; return -EAGAIN;
} else { } else {
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq); pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
irq = irq & 1 << INTR_IIR; irq = irq & 1 << INTR_IIR;
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, irq);
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq); pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
if (!(irq & (1 << INTR_IIR))) { if (!(irq & (1 << INTR_IIR))) {
atomisp_css2_hw_store_32(MRFLD_INTR_ENABLE_REG, 0x0); atomisp_css2_hw_store_32(MRFLD_INTR_ENABLE_REG, 0x0);
goto done; goto done;
...@@ -675,9 +665,9 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp) ...@@ -675,9 +665,9 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
* to IIR. It could block subsequent interrupt messages. * to IIR. It could block subsequent interrupt messages.
* HW sighting:4568410. * HW sighting:4568410.
*/ */
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq); pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
irq &= ~(1 << INTR_IER); irq &= ~(1 << INTR_IER);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, irq);
atomisp_msi_irq_uninit(isp); atomisp_msi_irq_uninit(isp);
atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true); atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
...@@ -1443,8 +1433,7 @@ atomisp_load_firmware(struct atomisp_device *isp) ...@@ -1443,8 +1433,7 @@ atomisp_load_firmware(struct atomisp_device *isp)
* Check for flags the driver was compiled with against the PCI * Check for flags the driver was compiled with against the PCI
* device. Always returns true on other than ISP 2400. * device. Always returns true on other than ISP 2400.
*/ */
static bool is_valid_device(struct pci_dev *dev, static bool is_valid_device(struct pci_dev *pdev, const struct pci_device_id *id)
const struct pci_device_id *id)
{ {
unsigned int a0_max_id = 0; unsigned int a0_max_id = 0;
const char *name; const char *name;
...@@ -1468,14 +1457,14 @@ static bool is_valid_device(struct pci_dev *dev, ...@@ -1468,14 +1457,14 @@ static bool is_valid_device(struct pci_dev *dev,
name = "Cherrytrail"; name = "Cherrytrail";
break; break;
default: default:
dev_err(&dev->dev, "%s: unknown device ID %x04:%x04\n", dev_err(&pdev->dev, "%s: unknown device ID %x04:%x04\n",
product, id->vendor, id->device); product, id->vendor, id->device);
return false; return false;
} }
if (dev->revision <= ATOMISP_PCI_REV_BYT_A0_MAX) { if (pdev->revision <= ATOMISP_PCI_REV_BYT_A0_MAX) {
dev_err(&dev->dev, "%s revision %d is not unsupported\n", dev_err(&pdev->dev, "%s revision %d is not unsupported\n",
name, dev->revision); name, pdev->revision);
return false; return false;
} }
...@@ -1486,22 +1475,20 @@ static bool is_valid_device(struct pci_dev *dev, ...@@ -1486,22 +1475,20 @@ static bool is_valid_device(struct pci_dev *dev,
#if defined(ISP2400) #if defined(ISP2400)
if (IS_ISP2401) { if (IS_ISP2401) {
dev_err(&dev->dev, "Support for %s (ISP2401) was disabled at compile time\n", dev_err(&pdev->dev, "Support for %s (ISP2401) was disabled at compile time\n",
name); name);
return false; return false;
} }
#else #else
if (!IS_ISP2401) { if (!IS_ISP2401) {
dev_err(&dev->dev, "Support for %s (ISP2400) was disabled at compile time\n", dev_err(&pdev->dev, "Support for %s (ISP2400) was disabled at compile time\n",
name); name);
return false; return false;
} }
#endif #endif
dev_info(&dev->dev, "Detected %s version %d (ISP240%c) on %s\n", dev_info(&pdev->dev, "Detected %s version %d (ISP240%c) on %s\n",
name, dev->revision, name, pdev->revision, IS_ISP2401 ? '1' : '0', product);
IS_ISP2401 ? '1' : '0',
product);
return true; return true;
} }
...@@ -1541,8 +1528,7 @@ static int init_atomisp_wdts(struct atomisp_device *isp) ...@@ -1541,8 +1528,7 @@ static int init_atomisp_wdts(struct atomisp_device *isp)
#define ATOM_ISP_PCI_BAR 0 #define ATOM_ISP_PCI_BAR 0
static int atomisp_pci_probe(struct pci_dev *dev, static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
const struct pci_device_id *id)
{ {
const struct atomisp_platform_data *pdata; const struct atomisp_platform_data *pdata;
struct atomisp_device *isp; struct atomisp_device *isp;
...@@ -1551,47 +1537,45 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1551,47 +1537,45 @@ static int atomisp_pci_probe(struct pci_dev *dev,
int err, val; int err, val;
u32 irq; u32 irq;
if (!is_valid_device(dev, id)) if (!is_valid_device(pdev, id))
return -ENODEV; return -ENODEV;
/* Pointer to struct device. */ /* Pointer to struct device. */
atomisp_dev = &dev->dev; atomisp_dev = &pdev->dev;
pdata = atomisp_get_platform_data(); pdata = atomisp_get_platform_data();
if (!pdata) if (!pdata)
dev_warn(&dev->dev, "no platform data available\n"); dev_warn(&pdev->dev, "no platform data available\n");
err = pcim_enable_device(dev); err = pcim_enable_device(pdev);
if (err) { if (err) {
dev_err(&dev->dev, "Failed to enable CI ISP device (%d)\n", dev_err(&pdev->dev, "Failed to enable CI ISP device (%d)\n", err);
err);
return err; return err;
} }
start = pci_resource_start(dev, ATOM_ISP_PCI_BAR); start = pci_resource_start(pdev, ATOM_ISP_PCI_BAR);
dev_dbg(&dev->dev, "start: 0x%x\n", start); dev_dbg(&pdev->dev, "start: 0x%x\n", start);
err = pcim_iomap_regions(dev, 1 << ATOM_ISP_PCI_BAR, pci_name(dev)); err = pcim_iomap_regions(pdev, 1 << ATOM_ISP_PCI_BAR, pci_name(pdev));
if (err) { if (err) {
dev_err(&dev->dev, "Failed to I/O memory remapping (%d)\n", dev_err(&pdev->dev, "Failed to I/O memory remapping (%d)\n", err);
err);
goto ioremap_fail; goto ioremap_fail;
} }
base = pcim_iomap_table(dev)[ATOM_ISP_PCI_BAR]; base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
dev_dbg(&dev->dev, "base: %p\n", base); dev_dbg(&pdev->dev, "base: %p\n", base);
atomisp_io_base = base; atomisp_io_base = base;
dev_dbg(&dev->dev, "atomisp_io_base: %p\n", atomisp_io_base); dev_dbg(&pdev->dev, "atomisp_io_base: %p\n", atomisp_io_base);
isp = devm_kzalloc(&dev->dev, sizeof(struct atomisp_device), GFP_KERNEL); isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
if (!isp) { if (!isp) {
err = -ENOMEM; err = -ENOMEM;
goto atomisp_dev_alloc_fail; goto atomisp_dev_alloc_fail;
} }
isp->dev = &dev->dev; isp->dev = &pdev->dev;
isp->sw_contex.power_state = ATOM_ISP_POWER_UP; isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
isp->saved_regs.ispmmadr = start; isp->saved_regs.ispmmadr = start;
...@@ -1600,7 +1584,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1600,7 +1584,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
spin_lock_init(&isp->lock); spin_lock_init(&isp->lock);
/* This is not a true PCI device on SoC, so the delay is not needed. */ /* This is not a true PCI device on SoC, so the delay is not needed. */
dev->d3_delay = 0; pdev->d3_delay = 0;
switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) { switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
case ATOMISP_PCI_DEVICE_SOC_MRFLD: case ATOMISP_PCI_DEVICE_SOC_MRFLD:
...@@ -1651,15 +1635,14 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1651,15 +1635,14 @@ static int atomisp_pci_probe(struct pci_dev *dev,
* have specs yet for exactly how it varies. Default to * have specs yet for exactly how it varies. Default to
* BYT-CR but let provisioning set it via EFI variable * BYT-CR but let provisioning set it via EFI variable
*/ */
isp->hpll_freq = gmin_get_var_int(&dev->dev, false, "HpllFreq", isp->hpll_freq = gmin_get_var_int(&pdev->dev, false, "HpllFreq", HPLL_FREQ_2000MHZ);
HPLL_FREQ_2000MHZ);
/* /*
* for BYT/CHT we are put isp into D3cold to avoid pci registers access * for BYT/CHT we are put isp into D3cold to avoid pci registers access
* in power off. Set d3cold_delay to 0 since default 100ms is not * in power off. Set d3cold_delay to 0 since default 100ms is not
* necessary. * necessary.
*/ */
dev->d3cold_delay = 0; pdev->d3cold_delay = 0;
break; break;
case ATOMISP_PCI_DEVICE_SOC_ANN: case ATOMISP_PCI_DEVICE_SOC_ANN:
isp->media_dev.hw_revision = ( isp->media_dev.hw_revision = (
...@@ -1669,7 +1652,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1669,7 +1652,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
ATOMISP_HW_REVISION_ISP2401_LEGACY ATOMISP_HW_REVISION_ISP2401_LEGACY
#endif #endif
<< ATOMISP_HW_REVISION_SHIFT); << ATOMISP_HW_REVISION_SHIFT);
isp->media_dev.hw_revision |= dev->revision < 2 ? isp->media_dev.hw_revision |= pdev->revision < 2 ?
ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0; ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
isp->dfs = &dfs_config_merr; isp->dfs = &dfs_config_merr;
isp->hpll_freq = HPLL_FREQ_1600MHZ; isp->hpll_freq = HPLL_FREQ_1600MHZ;
...@@ -1682,11 +1665,11 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1682,11 +1665,11 @@ static int atomisp_pci_probe(struct pci_dev *dev,
ATOMISP_HW_REVISION_ISP2401_LEGACY ATOMISP_HW_REVISION_ISP2401_LEGACY
#endif #endif
<< ATOMISP_HW_REVISION_SHIFT); << ATOMISP_HW_REVISION_SHIFT);
isp->media_dev.hw_revision |= dev->revision < 2 ? isp->media_dev.hw_revision |= pdev->revision < 2 ?
ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0; ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
isp->dfs = &dfs_config_cht; isp->dfs = &dfs_config_cht;
dev->d3cold_delay = 0; pdev->d3cold_delay = 0;
iosf_mbi_read(BT_MBI_UNIT_CCK, MBI_REG_READ, CCK_FUSE_REG_0, &val); iosf_mbi_read(BT_MBI_UNIT_CCK, MBI_REG_READ, CCK_FUSE_REG_0, &val);
switch (val & CCK_FUSE_HPLL_FREQ_MASK) { switch (val & CCK_FUSE_HPLL_FREQ_MASK) {
...@@ -1701,18 +1684,16 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1701,18 +1684,16 @@ static int atomisp_pci_probe(struct pci_dev *dev,
break; break;
default: default:
isp->hpll_freq = HPLL_FREQ_1600MHZ; isp->hpll_freq = HPLL_FREQ_1600MHZ;
dev_warn(isp->dev, dev_warn(&pdev->dev, "read HPLL from cck failed. Default to 1600 MHz.\n");
"read HPLL from cck failed. Default to 1600 MHz.\n");
} }
break; break;
default: default:
dev_err(&dev->dev, "un-supported IUNIT device\n"); dev_err(&pdev->dev, "un-supported IUNIT device\n");
err = -ENODEV; err = -ENODEV;
goto atomisp_dev_alloc_fail; goto atomisp_dev_alloc_fail;
} }
dev_info(&dev->dev, "ISP HPLL frequency base = %d MHz\n", dev_info(&pdev->dev, "ISP HPLL frequency base = %d MHz\n", isp->hpll_freq);
isp->hpll_freq);
isp->max_isr_latency = ATOMISP_MAX_ISR_LATENCY; isp->max_isr_latency = ATOMISP_MAX_ISR_LATENCY;
...@@ -1721,26 +1702,25 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1721,26 +1702,25 @@ static int atomisp_pci_probe(struct pci_dev *dev,
isp->firmware = atomisp_load_firmware(isp); isp->firmware = atomisp_load_firmware(isp);
if (!isp->firmware) { if (!isp->firmware) {
err = -ENOENT; err = -ENOENT;
dev_dbg(&dev->dev, "Firmware load failed\n"); dev_dbg(&pdev->dev, "Firmware load failed\n");
goto load_fw_fail; goto load_fw_fail;
} }
err = sh_css_check_firmware_version(isp->dev, err = sh_css_check_firmware_version(isp->dev, isp->firmware->data);
isp->firmware->data);
if (err) { if (err) {
dev_dbg(&dev->dev, "Firmware version check failed\n"); dev_dbg(&pdev->dev, "Firmware version check failed\n");
goto fw_validation_fail; goto fw_validation_fail;
} }
} else { } else {
dev_info(&dev->dev, "Firmware load will be deferred\n"); dev_info(&pdev->dev, "Firmware load will be deferred\n");
} }
pci_set_master(dev); pci_set_master(pdev);
pci_set_drvdata(dev, isp); pci_set_drvdata(pdev, isp);
err = pci_enable_msi(dev); err = pci_enable_msi(pdev);
if (err) { if (err) {
dev_err(&dev->dev, "Failed to enable msi (%d)\n", err); dev_err(&pdev->dev, "Failed to enable msi (%d)\n", err);
goto enable_msi_fail; goto enable_msi_fail;
} }
...@@ -1765,8 +1745,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1765,8 +1745,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
* Workaround for imbalance data eye issue which is observed * Workaround for imbalance data eye issue which is observed
* on TNG B0. * on TNG B0.
*/ */
pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, pci_read_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, &csi_afe_trim);
&csi_afe_trim);
csi_afe_trim &= ~((MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << csi_afe_trim &= ~((MRFLD_PCI_CSI_HSRXCLKTRIM_MASK <<
MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) | MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) |
(MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << (MRFLD_PCI_CSI_HSRXCLKTRIM_MASK <<
...@@ -1779,20 +1758,18 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1779,20 +1758,18 @@ static int atomisp_pci_probe(struct pci_dev *dev,
MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) | MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) |
(MRFLD_PCI_CSI3_HSRXCLKTRIM << (MRFLD_PCI_CSI3_HSRXCLKTRIM <<
MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT); MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT);
pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, pci_write_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, csi_afe_trim);
csi_afe_trim);
} }
err = atomisp_initialize_modules(isp); err = atomisp_initialize_modules(isp);
if (err < 0) { if (err < 0) {
dev_err(&dev->dev, "atomisp_initialize_modules (%d)\n", err); dev_err(&pdev->dev, "atomisp_initialize_modules (%d)\n", err);
goto initialize_modules_fail; goto initialize_modules_fail;
} }
err = atomisp_register_entities(isp); err = atomisp_register_entities(isp);
if (err < 0) { if (err < 0) {
dev_err(&dev->dev, "atomisp_register_entities failed (%d)\n", dev_err(&pdev->dev, "atomisp_register_entities failed (%d)\n", err);
err);
goto register_entities_fail; goto register_entities_fail;
} }
err = atomisp_create_pads_links(isp); err = atomisp_create_pads_links(isp);
...@@ -1805,24 +1782,24 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1805,24 +1782,24 @@ static int atomisp_pci_probe(struct pci_dev *dev,
/* save the iunit context only once after all the values are init'ed. */ /* save the iunit context only once after all the values are init'ed. */
atomisp_save_iunit_reg(isp); atomisp_save_iunit_reg(isp);
pm_runtime_put_noidle(&dev->dev); pm_runtime_put_noidle(&pdev->dev);
pm_runtime_allow(&dev->dev); pm_runtime_allow(&pdev->dev);
hmm_init_mem_stat(repool_pgnr, dypool_enable, dypool_pgnr); hmm_init_mem_stat(repool_pgnr, dypool_enable, dypool_pgnr);
err = hmm_pool_register(repool_pgnr, HMM_POOL_TYPE_RESERVED); err = hmm_pool_register(repool_pgnr, HMM_POOL_TYPE_RESERVED);
if (err) { if (err) {
dev_err(&dev->dev, "Failed to register reserved memory pool.\n"); dev_err(&pdev->dev, "Failed to register reserved memory pool.\n");
goto hmm_pool_fail; goto hmm_pool_fail;
} }
/* Init ISP memory management */ /* Init ISP memory management */
hmm_init(); hmm_init();
err = devm_request_threaded_irq(&dev->dev, dev->irq, err = devm_request_threaded_irq(&pdev->dev, pdev->irq,
atomisp_isr, atomisp_isr_thread, atomisp_isr, atomisp_isr_thread,
IRQF_SHARED, "isp_irq", isp); IRQF_SHARED, "isp_irq", isp);
if (err) { if (err) {
dev_err(&dev->dev, "Failed to request irq (%d)\n", err); dev_err(&pdev->dev, "Failed to request irq (%d)\n", err);
goto request_irq_fail; goto request_irq_fail;
} }
...@@ -1830,11 +1807,11 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1830,11 +1807,11 @@ static int atomisp_pci_probe(struct pci_dev *dev,
if (!defer_fw_load) { if (!defer_fw_load) {
err = atomisp_css_load_firmware(isp); err = atomisp_css_load_firmware(isp);
if (err) { if (err) {
dev_err(&dev->dev, "Failed to init css.\n"); dev_err(&pdev->dev, "Failed to init css.\n");
goto css_init_fail; goto css_init_fail;
} }
} else { } else {
dev_dbg(&dev->dev, "Skip css init.\n"); dev_dbg(&pdev->dev, "Skip css init.\n");
} }
/* Clear FW image from memory */ /* Clear FW image from memory */
release_firmware(isp->firmware); release_firmware(isp->firmware);
...@@ -1846,7 +1823,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1846,7 +1823,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
return 0; return 0;
css_init_fail: css_init_fail:
devm_free_irq(&dev->dev, dev->irq, isp); devm_free_irq(&pdev->dev, pdev->irq, isp);
request_irq_fail: request_irq_fail:
hmm_cleanup(); hmm_cleanup();
hmm_pool_unregister(HMM_POOL_TYPE_RESERVED); hmm_pool_unregister(HMM_POOL_TYPE_RESERVED);
...@@ -1860,7 +1837,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1860,7 +1837,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
initialize_modules_fail: initialize_modules_fail:
cpu_latency_qos_remove_request(&isp->pm_qos); cpu_latency_qos_remove_request(&isp->pm_qos);
atomisp_msi_irq_uninit(isp); atomisp_msi_irq_uninit(isp);
pci_disable_msi(dev); pci_disable_msi(pdev);
enable_msi_fail: enable_msi_fail:
fw_validation_fail: fw_validation_fail:
release_firmware(isp->firmware); release_firmware(isp->firmware);
...@@ -1872,13 +1849,13 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1872,13 +1849,13 @@ static int atomisp_pci_probe(struct pci_dev *dev,
* The following lines have been copied from atomisp suspend path * The following lines have been copied from atomisp suspend path
*/ */
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq); pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
irq = irq & 1 << INTR_IIR; irq = irq & 1 << INTR_IIR;
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, irq);
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq); pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq);
irq &= ~(1 << INTR_IER); irq &= ~(1 << INTR_IER);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, irq);
atomisp_msi_irq_uninit(isp); atomisp_msi_irq_uninit(isp);
...@@ -1886,21 +1863,20 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1886,21 +1863,20 @@ static int atomisp_pci_probe(struct pci_dev *dev,
/* Address later when we worry about the ...field chips */ /* Address later when we worry about the ...field chips */
if (IS_ENABLED(CONFIG_PM) && atomisp_mrfld_power_down(isp)) if (IS_ENABLED(CONFIG_PM) && atomisp_mrfld_power_down(isp))
dev_err(&dev->dev, "Failed to switch off ISP\n"); dev_err(&pdev->dev, "Failed to switch off ISP\n");
atomisp_dev_alloc_fail: atomisp_dev_alloc_fail:
pcim_iounmap_regions(dev, 1 << ATOM_ISP_PCI_BAR); pcim_iounmap_regions(pdev, 1 << ATOM_ISP_PCI_BAR);
ioremap_fail: ioremap_fail:
return err; return err;
} }
static void atomisp_pci_remove(struct pci_dev *dev) static void atomisp_pci_remove(struct pci_dev *pdev)
{ {
struct atomisp_device *isp = (struct atomisp_device *) struct atomisp_device *isp = pci_get_drvdata(pdev);
pci_get_drvdata(dev);
dev_info(&dev->dev, "Removing atomisp driver\n"); dev_info(&pdev->dev, "Removing atomisp driver\n");
atomisp_drvfs_exit(); atomisp_drvfs_exit();
...@@ -1909,8 +1885,8 @@ static void atomisp_pci_remove(struct pci_dev *dev) ...@@ -1909,8 +1885,8 @@ static void atomisp_pci_remove(struct pci_dev *dev)
ia_css_unload_firmware(); ia_css_unload_firmware();
hmm_cleanup(); hmm_cleanup();
pm_runtime_forbid(&dev->dev); pm_runtime_forbid(&pdev->dev);
pm_runtime_get_noresume(&dev->dev); pm_runtime_get_noresume(&pdev->dev);
cpu_latency_qos_remove_request(&isp->pm_qos); cpu_latency_qos_remove_request(&isp->pm_qos);
atomisp_msi_irq_uninit(isp); atomisp_msi_irq_uninit(isp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment