All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: intel_pmc_mux: Update IOM port status offset for AlderLake
@ 2021-05-25  2:04 Azhar Shaikh
  2021-05-26  6:23 ` Heikki Krogerus
  0 siblings, 1 reply; 3+ messages in thread
From: Azhar Shaikh @ 2021-05-25  2:04 UTC (permalink / raw)
  To: heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel, azhar.shaikh

Intel AlderLake(ADL) IOM has a different IOM port status offset than
Intel TigerLake.
Add a new ACPI ID for ADL and use the IOM port status offset as per
the platform.

Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 28 ++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index 46a25b8db72e..5ef41cfa8213 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -83,8 +83,6 @@ enum {
 /*
  * Input Output Manager (IOM) PORT STATUS
  */
-#define IOM_PORT_STATUS_OFFSET				0x560
-
 #define IOM_PORT_STATUS_ACTIVITY_TYPE_MASK		GENMASK(9, 6)
 #define IOM_PORT_STATUS_ACTIVITY_TYPE_SHIFT		6
 #define IOM_PORT_STATUS_ACTIVITY_TYPE_USB		0x03
@@ -144,6 +142,7 @@ struct pmc_usb {
 	struct pmc_usb_port *port;
 	struct acpi_device *iom_adev;
 	void __iomem *iom_base;
+	u32 iom_port_status_offset;
 };
 
 static void update_port_status(struct pmc_usb_port *port)
@@ -153,7 +152,8 @@ static void update_port_status(struct pmc_usb_port *port)
 	/* SoC expects the USB Type-C port numbers to start with 0 */
 	port_num = port->usb3_port - 1;
 
-	port->iom_status = readl(port->pmc->iom_base + IOM_PORT_STATUS_OFFSET +
+	port->iom_status = readl(port->pmc->iom_base +
+				 port->pmc->iom_port_status_offset +
 				 port_num * sizeof(u32));
 }
 
@@ -559,14 +559,32 @@ static int is_memory(struct acpi_resource *res, void *data)
 	return !acpi_dev_resource_memory(res, &r);
 }
 
+/* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */
+static const struct acpi_device_id iom_acpi_ids[] = {
+	/* TigerLake */
+	{ "INTC1072", 0x560, },
+
+	/* AlderLake */
+	{ "INTC1079", 0x160, },
+	{}
+};
+
 static int pmc_usb_probe_iom(struct pmc_usb *pmc)
 {
 	struct list_head resource_list;
 	struct resource_entry *rentry;
-	struct acpi_device *adev;
+	static const struct acpi_device_id *id;
+	struct acpi_device *adev = NULL;
 	int ret;
 
-	adev = acpi_dev_get_first_match_dev("INTC1072", NULL, -1);
+	for (id = &iom_acpi_ids[0]; id->id[0]; id++) {
+		if (acpi_dev_present((const char *)id, NULL, -1)) {
+			pmc->iom_port_status_offset = (u32)id->driver_data;
+			adev = acpi_dev_get_first_match_dev((const char *)id, NULL, -1);
+			break;
+		}
+	}
+
 	if (!adev)
 		return -ENODEV;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: intel_pmc_mux: Update IOM port status offset for AlderLake
  2021-05-25  2:04 [PATCH] usb: typec: intel_pmc_mux: Update IOM port status offset for AlderLake Azhar Shaikh
@ 2021-05-26  6:23 ` Heikki Krogerus
  2021-05-26 22:11   ` Shaikh, Azhar
  0 siblings, 1 reply; 3+ messages in thread
From: Heikki Krogerus @ 2021-05-26  6:23 UTC (permalink / raw)
  To: Azhar Shaikh; +Cc: gregkh, linux-usb, linux-kernel

On Mon, May 24, 2021 at 07:04:01PM -0700, Azhar Shaikh wrote:
> Intel AlderLake(ADL) IOM has a different IOM port status offset than
> Intel TigerLake.
> Add a new ACPI ID for ADL and use the IOM port status offset as per
> the platform.
> 
> Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
> ---
>  drivers/usb/typec/mux/intel_pmc_mux.c | 28 ++++++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
> index 46a25b8db72e..5ef41cfa8213 100644
> --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> @@ -83,8 +83,6 @@ enum {
>  /*
>   * Input Output Manager (IOM) PORT STATUS
>   */
> -#define IOM_PORT_STATUS_OFFSET				0x560
> -
>  #define IOM_PORT_STATUS_ACTIVITY_TYPE_MASK		GENMASK(9, 6)
>  #define IOM_PORT_STATUS_ACTIVITY_TYPE_SHIFT		6
>  #define IOM_PORT_STATUS_ACTIVITY_TYPE_USB		0x03
> @@ -144,6 +142,7 @@ struct pmc_usb {
>  	struct pmc_usb_port *port;
>  	struct acpi_device *iom_adev;
>  	void __iomem *iom_base;
> +	u32 iom_port_status_offset;
>  };
>  
>  static void update_port_status(struct pmc_usb_port *port)
> @@ -153,7 +152,8 @@ static void update_port_status(struct pmc_usb_port *port)
>  	/* SoC expects the USB Type-C port numbers to start with 0 */
>  	port_num = port->usb3_port - 1;
>  
> -	port->iom_status = readl(port->pmc->iom_base + IOM_PORT_STATUS_OFFSET +
> +	port->iom_status = readl(port->pmc->iom_base +
> +				 port->pmc->iom_port_status_offset +
>  				 port_num * sizeof(u32));
>  }
>  
> @@ -559,14 +559,32 @@ static int is_memory(struct acpi_resource *res, void *data)
>  	return !acpi_dev_resource_memory(res, &r);
>  }
>  
> +/* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */
> +static const struct acpi_device_id iom_acpi_ids[] = {
> +	/* TigerLake */
> +	{ "INTC1072", 0x560, },
> +
> +	/* AlderLake */
> +	{ "INTC1079", 0x160, },
> +	{}
> +};
> +
>  static int pmc_usb_probe_iom(struct pmc_usb *pmc)
>  {
>  	struct list_head resource_list;
>  	struct resource_entry *rentry;
> -	struct acpi_device *adev;
> +	static const struct acpi_device_id *id;
> +	struct acpi_device *adev = NULL;
>  	int ret;
>  
> -	adev = acpi_dev_get_first_match_dev("INTC1072", NULL, -1);
> +	for (id = &iom_acpi_ids[0]; id->id[0]; id++) {
> +		if (acpi_dev_present((const char *)id, NULL, -1)) {
> +			pmc->iom_port_status_offset = (u32)id->driver_data;
> +			adev = acpi_dev_get_first_match_dev((const char *)id, NULL, -1);

This one I think you still need to change:

                        adev = acpi_dev_get_first_match_dev(id->id, NULL, -1)

> +			break;
> +		}
> +	}
> +
>  	if (!adev)
>  		return -ENODEV;
>  

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] usb: typec: intel_pmc_mux: Update IOM port status offset for AlderLake
  2021-05-26  6:23 ` Heikki Krogerus
@ 2021-05-26 22:11   ` Shaikh, Azhar
  0 siblings, 0 replies; 3+ messages in thread
From: Shaikh, Azhar @ 2021-05-26 22:11 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: gregkh, linux-usb, linux-kernel



> -----Original Message-----
> From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Sent: Tuesday, May 25, 2021 11:24 PM
> To: Shaikh, Azhar <azhar.shaikh@intel.com>
> Cc: gregkh@linuxfoundation.org; linux-usb@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH] usb: typec: intel_pmc_mux: Update IOM port status
> offset for AlderLake
> 
> On Mon, May 24, 2021 at 07:04:01PM -0700, Azhar Shaikh wrote:
> > Intel AlderLake(ADL) IOM has a different IOM port status offset than
> > Intel TigerLake.
> > Add a new ACPI ID for ADL and use the IOM port status offset as per
> > the platform.
> >
> > Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com>
> > ---
> >  drivers/usb/typec/mux/intel_pmc_mux.c | 28
> > ++++++++++++++++++++++-----
> >  1 file changed, 23 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c
> > b/drivers/usb/typec/mux/intel_pmc_mux.c
> > index 46a25b8db72e..5ef41cfa8213 100644
> > --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> > +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> > @@ -83,8 +83,6 @@ enum {
> >  /*
> >   * Input Output Manager (IOM) PORT STATUS
> >   */
> > -#define IOM_PORT_STATUS_OFFSET				0x560
> > -
> >  #define IOM_PORT_STATUS_ACTIVITY_TYPE_MASK		GENMASK(9,
> 6)
> >  #define IOM_PORT_STATUS_ACTIVITY_TYPE_SHIFT		6
> >  #define IOM_PORT_STATUS_ACTIVITY_TYPE_USB		0x03
> > @@ -144,6 +142,7 @@ struct pmc_usb {
> >  	struct pmc_usb_port *port;
> >  	struct acpi_device *iom_adev;
> >  	void __iomem *iom_base;
> > +	u32 iom_port_status_offset;
> >  };
> >
> >  static void update_port_status(struct pmc_usb_port *port) @@ -153,7
> > +152,8 @@ static void update_port_status(struct pmc_usb_port *port)
> >  	/* SoC expects the USB Type-C port numbers to start with 0 */
> >  	port_num = port->usb3_port - 1;
> >
> > -	port->iom_status = readl(port->pmc->iom_base +
> IOM_PORT_STATUS_OFFSET +
> > +	port->iom_status = readl(port->pmc->iom_base +
> > +				 port->pmc->iom_port_status_offset +
> >  				 port_num * sizeof(u32));
> >  }
> >
> > @@ -559,14 +559,32 @@ static int is_memory(struct acpi_resource *res,
> void *data)
> >  	return !acpi_dev_resource_memory(res, &r);  }
> >
> > +/* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */ static const struct
> > +acpi_device_id iom_acpi_ids[] = {
> > +	/* TigerLake */
> > +	{ "INTC1072", 0x560, },
> > +
> > +	/* AlderLake */
> > +	{ "INTC1079", 0x160, },
> > +	{}
> > +};
> > +
> >  static int pmc_usb_probe_iom(struct pmc_usb *pmc)  {
> >  	struct list_head resource_list;
> >  	struct resource_entry *rentry;
> > -	struct acpi_device *adev;
> > +	static const struct acpi_device_id *id;
> > +	struct acpi_device *adev = NULL;
> >  	int ret;
> >
> > -	adev = acpi_dev_get_first_match_dev("INTC1072", NULL, -1);
> > +	for (id = &iom_acpi_ids[0]; id->id[0]; id++) {
> > +		if (acpi_dev_present((const char *)id, NULL, -1)) {

Also here I think it should be 
if (acpi_dev_present((id->id, NULL, -1)) {

> > +			pmc->iom_port_status_offset = (u32)id-
> >driver_data;
> > +			adev = acpi_dev_get_first_match_dev((const char
> *)id, NULL, -1);
> 
> This one I think you still need to change:
> 
>                         adev = acpi_dev_get_first_match_dev(id->id, NULL, -1)
> 

Yup. Will fix this.

> > +			break;
> > +		}
> > +	}
> > +
> >  	if (!adev)
> >  		return -ENODEV;
> >
> 
> thanks,
> 
> --
> heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-26 22:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25  2:04 [PATCH] usb: typec: intel_pmc_mux: Update IOM port status offset for AlderLake Azhar Shaikh
2021-05-26  6:23 ` Heikki Krogerus
2021-05-26 22:11   ` Shaikh, Azhar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.