Commit ca133c39 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: atomisp: improve device detection code

- Remove useless check if !dev at the probe function: if
  such function is called, the device is defined.
- Cleanup the PCI ID table using macros.
- Use the same macros at the version-dependent part of the
  atomisp_v4l2.c file;
- Add print messages to help understand what model the
  driver detect;
- If device is not valid, better explain why.
Signed-off-by: default avatarMauro Carvalho Chehehab <mchehab+huawei@kernel.org>
parent 9b7632e8
...@@ -1462,20 +1462,64 @@ atomisp_load_firmware(struct atomisp_device *isp) ...@@ -1462,20 +1462,64 @@ atomisp_load_firmware(struct atomisp_device *isp)
static bool is_valid_device(struct pci_dev *dev, static bool is_valid_device(struct pci_dev *dev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
unsigned int a0_max_id; unsigned int a0_max_id = 0;
const char *name;
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:
a0_max_id = ATOMISP_PCI_REV_MRFLD_A0_MAX; a0_max_id = ATOMISP_PCI_REV_MRFLD_A0_MAX;
atomisp_hw_is_isp2401 = false;
name = "Merrifield";
break; break;
case ATOMISP_PCI_DEVICE_SOC_BYT: case ATOMISP_PCI_DEVICE_SOC_BYT:
a0_max_id = ATOMISP_PCI_REV_BYT_A0_MAX; a0_max_id = ATOMISP_PCI_REV_BYT_A0_MAX;
atomisp_hw_is_isp2401 = false;
name = "Baytrail";
break;
case ATOMISP_PCI_DEVICE_SOC_ANN:
name = "Anniedale";
atomisp_hw_is_isp2401 = true;
break;
case ATOMISP_PCI_DEVICE_SOC_CHT:
name = "Cherrytrail";
atomisp_hw_is_isp2401 = true;
break; break;
default: default:
return true; dev_err(&dev->dev, "Unknown device ID %x04:%x04\n",
id->vendor, id->device);
return false;
}
if (dev->revision <= ATOMISP_PCI_REV_BYT_A0_MAX) {
dev_err(&dev->dev, "%s revision %d is not unsupported\n",
name, dev->revision);
return false;
}
/*
* FIXME:
* remove the if once the driver become generic
*/
#if defined(ISP2400)
if (atomisp_hw_is_isp2401) {
dev_err(&dev->dev, "Support for %s (ISP2401) was disabled at compile time\n",
name);
return false;
} }
#else
if (!atomisp_hw_is_isp2401) {
dev_err(&dev->dev, "Support for %s (ISP2400) was disabled at compile time\n",
name);
return false;
}
#endif
return dev->revision > a0_max_id; dev_info(&dev->dev, "Detected %s version %d (ISP240%c)\n",
name, dev->revision,
atomisp_hw_is_isp2401 ? '1' : '0');
return true;
} }
static int init_atomisp_wdts(struct atomisp_device *isp) static int init_atomisp_wdts(struct atomisp_device *isp)
...@@ -1522,21 +1566,12 @@ static int atomisp_pci_probe(struct pci_dev *dev, ...@@ -1522,21 +1566,12 @@ static int atomisp_pci_probe(struct pci_dev *dev,
int err, val; int err, val;
u32 irq; u32 irq;
if (!dev) {
dev_err(&dev->dev, "atomisp: error device ptr\n");
return -EINVAL;
}
if (!is_valid_device(dev, id)) if (!is_valid_device(dev, id))
return -ENODEV; return -ENODEV;
/* Pointer to struct device. */ /* Pointer to struct device. */
atomisp_dev = &dev->dev; atomisp_dev = &dev->dev;
if (id->driver_data == HW_IS_ISP2401)
atomisp_hw_is_isp2401 = true;
else
atomisp_hw_is_isp2401 = false;
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(&dev->dev, "no platform data available\n");
...@@ -1892,23 +1927,16 @@ static void atomisp_pci_remove(struct pci_dev *dev) ...@@ -1892,23 +1927,16 @@ static void atomisp_pci_remove(struct pci_dev *dev)
} }
static const struct pci_device_id atomisp_pci_tbl[] = { static const struct pci_device_id atomisp_pci_tbl[] = {
/*
* FIXME:
* remove the ifs once we get rid of the ifs on other parts of the driver
*/
#if defined(ISP2400)
/* Merrifield */ /* Merrifield */
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1178), .driver_data = HW_IS_ISP2400}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ATOMISP_PCI_DEVICE_SOC_MRFLD)},
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1179), .driver_data = HW_IS_ISP2400}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ATOMISP_PCI_DEVICE_SOC_MRFLD_1179)},
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x117a), .driver_data = HW_IS_ISP2400}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ATOMISP_PCI_DEVICE_SOC_MRFLD_117A)},
/* Baytrail */ /* Baytrail */
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0f38), .driver_data = HW_IS_ISP2400}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ATOMISP_PCI_DEVICE_SOC_BYT)},
#elif defined(ISP2401)
/* Anniedale (Merrifield+ / Moorefield) */ /* Anniedale (Merrifield+ / Moorefield) */
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1478), .driver_data = HW_IS_ISP2401}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ATOMISP_PCI_DEVICE_SOC_ANN)},
/* Cherrytrail */ /* Cherrytrail */
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x22b8), .driver_data = HW_IS_ISP2401}, {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ATOMISP_PCI_DEVICE_SOC_CHT)},
#endif
{0,} {0,}
}; };
......
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