Re: [PATCH v6 2/4] SFH: PCIe driver to add support of AMD sensor fusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 9, 2020 at 1:25 PM Sandeep Singh <Sandeep.Singh@xxxxxxx> wrote:

> AMD SFH uses HID over PCIe bus.SFH fw is part of MP2 processor
> (MP2 which is an ARM® Cortex-M4 core based co-processor to x86) and
> it runs on MP2 where in driver resides on X86. This part of module

where the driver

> will communicate with MP2 FW and provide that data into DRAM

...

> +#
> +#

One is enough.

...

> +#define ACEL_EN                BIT(accel_idx)
> +#define GYRO_EN                BIT(gyro_idx)
> +#define MAGNO_EN       BIT(mag_idx)
> +#define ALS_EN         BIT(als_idx)

What is this?

...

> +int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
> +{
> +       int activestatus, num_of_sensors = 0;
> +

> +       if (!sensor_id)
> +               return -EINVAL;

Is it possible?

> +       privdata->activecontrolstatus = readl(privdata->mmio + AMD_P2C_MSG3);
> +       activestatus = privdata->activecontrolstatus >> 4;
> +       if (ACEL_EN  & activestatus)
> +               sensor_id[num_of_sensors++] = accel_idx;
> +
> +       if (GYRO_EN & activestatus)
> +               sensor_id[num_of_sensors++] = gyro_idx;
> +
> +       if (MAGNO_EN & activestatus)
> +               sensor_id[num_of_sensors++] = mag_idx;
> +
> +       if (ALS_EN & activestatus)
> +               sensor_id[num_of_sensors++] = als_idx;
> +
> +       return num_of_sensors;
> +}

...

> +static int amd_mp2_pci_init(struct amd_mp2_dev *privdata, struct pci_dev *pdev)
> +{
> +       int rc;
> +

> +       pci_set_drvdata(pdev, privdata);

This is better to have after initial resources were retrieved.

> +       pcim_enable_device(pdev);

> +       pcim_iomap_regions(pdev, BIT(2), DRIVER_NAME);

Where is the error check?

> +       privdata->mmio = pcim_iomap_table(pdev)[2];
> +       pci_set_master(pdev);
> +
> +       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
> +       if (rc)
> +               rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> +       return rc;
> +}

What is the point to have this function separated from ->probe()?

...

> +       rc = amd_sfh_hid_client_init(privdata);
> +       if (rc)
> +               return rc;
> +       return 0;

return amd_...(...);

...

> +static const struct pci_device_id amd_mp2_pci_tbl[] = {
> +       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2) },

> +       {},

No comma.

> +};

...

> +#include <linux/pci.h>

I don't see any users of it in the file.
Use forward declaration instead.

> +#include <linux/types.h>

...

> +enum command_id {
> +       enable_sensor = 1,
> +       disable_sensor = 2,
> +       stop_all_sensors = 8,

> +       invalid_cmd = 0xf

GENMASK()?
(Will require bits.h)

> +};
> +
> +enum sensor_idx {
> +       accel_idx = 0,
> +       gyro_idx = 1,
> +       mag_idx = 2,
> +       als_idx = 19

+ comma.

> +};
> +
> +struct amd_mp2_dev {
> +       struct pci_dev *pdev;
> +       struct amdtp_cl_data *cl_data;

> +       void __iomem *mmio;

Is __iomem provided by linux/types.h? Otherwise include corresponding header.

> +       u32 activecontrolstatus;
> +};

-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux