Re: [PATCH v10 13/13] mfd: nct6694: Add Host Interface (HIF) eSPI transport driver

From: Ming Yu

Date: Fri Nov 27 2026 - 01:45:12 EST


Hi Lee,

Thank you for reviewing.

Lee Jones <lee@xxxxxxxxxx> 於 2026年11月27日週五 上午3:58寫道:
>
...
> > +#include <linux/acpi.h>
> > +#include <linux/bitfield.h>
> > +#include <linux/bits.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/io.h>
> > +#include <linux/iopoll.h>
> > +#include <linux/irq.h>
> > +#include <linux/kernel.h>
> > +#include <linux/mfd/core.h>
> > +#include <linux/mfd/nct6694.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> > +#include <linux/unaligned.h>
> > +
> > +#define DRVNAME "nct6694-hif"
>
> Don't define strings like this. Use them in-place.
>

Will fix in v11.

> > +#define NCT6694_POLL_INTERVAL_US 10
> > +#define NCT6694_POLL_TIMEOUT_US 10000
> > +
> > +/*
> > + * Super-I/O registers
> > + */
>
> ... and this is a multi-line comment, because?
>

Will fix in v11.

> > +#define SIO_REG_LDSEL 0x07 /* Logical device select */
> > +#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
> > +#define SIO_REG_LD_SHM 0x0F /* Logical device shared memory control */
...
> > +static const char * const nct6694_chip_names[] = {
> > + [NCT6694B] = "NCT6694B",
> > + [NCT6694D] = "NCT6694D",
> > +};
>
> Remove this.
>

Will fix in v11.

> > +/*
> > + * Super-I/O functions.
> > + */
>
> Isn't this obvious by the nomenclature?
>

Will fix in v11.

> > +static inline int superio_enter(struct nct6694_sio_data *sio_data)
> > +{
> > + int ioreg = sio_data->sioreg;
> > +
> > + /*
> > + * Try to reserve <ioreg> and <ioreg + 1> for exclusive access.
> > + */
> > + if (!request_muxed_region(ioreg, 2, DRVNAME))
> > + return -EBUSY;
> > +
> > + outb(SIO_REG_UNLOCK_KEY, ioreg);
> > + outb(SIO_REG_UNLOCK_KEY, ioreg);
>
> How does this work then? Is this self-incrementing?
>

No, both writes go to the index port. The chip only enters
configuration mode after 0x87 is written twice, the same as in
nct6775-platform.c.

> > +
> > + return 0;
> > +}
> > +
> > +static inline void superio_exit(struct nct6694_sio_data *sio_data)
> > +{
> > + int ioreg = sio_data->sioreg;
> > +
> > + outb(SIO_REG_LOCK_KEY, ioreg);
>
> Remind me, why aren't we using regmap?
>

The Super-I/O ports are shared with other drivers, so each access has
to be wrapped in request_muxed_region() and the enter/exit sequence.
That's why I followed the existing Super-I/O drivers, e.g.
nct6775-platform.c, nct6683.c, w83627ehf.c, it87.c, gpio-f7188x.c and
w83627hf_wdt.c.

If you'd still prefer regmap here, I'm happy to rework it.

> > + release_region(ioreg, 2);
> > +}
> > +
...
> > + sio_data = devm_kzalloc_obj(dev, *sio_data);
> > + if (!sio_data)
> > + return -ENOMEM;
> > +
> > + for (i = 0; i < ARRAY_SIZE(sio_addrs); i++) {
>
> for (int i = 0; ...
>

Will fix in v11.

> > + if (!nct6694_sio_find(sio_data, sio_addrs[i]))
> > + break;
> > + }
> > + if (i == ARRAY_SIZE(sio_addrs))
> > + return -ENODEV;
> > +
> > + dev_dbg(dev, "Found %s at %#x\n", nct6694_chip_names[sio_data->chip], sio_data->sioreg);
>
> Remove debug prints from production code.
>

Will fix in v11.

> > + hif_data = devm_kzalloc_obj(dev, *hif_data);
> > + if (!hif_data)
> > + return -ENOMEM;
> > +
...

Thanks,
Ming