diff mbox series

[6/9] soc/tegra: fuse: Implement tegra_is_silicon()

Message ID 20200716141856.544718-7-thierry.reding@gmail.com
State Accepted
Headers show
Series arm64: tegra: Initial Tegra234 VDK support | expand

Commit Message

Thierry Reding July 16, 2020, 2:18 p.m. UTC
From: Thierry Reding <treding@nvidia.com>

This function can be used by drivers to determine whether code is
running on silicon or on a simulation platform.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/soc/tegra/fuse/tegra-apbmisc.c | 13 +++++++++++++
 include/soc/tegra/fuse.h               |  1 +
 2 files changed, 14 insertions(+)

Comments

Jon Hunter Sept. 7, 2020, 7:32 p.m. UTC | #1
On 16/07/2020 15:18, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> This function can be used by drivers to determine whether code is
> running on silicon or on a simulation platform.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/soc/tegra/fuse/tegra-apbmisc.c | 13 +++++++++++++
>  include/soc/tegra/fuse.h               |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c
> index 89f1479b4d0e..be6b7fc169ca 100644
> --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
> +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
> @@ -52,6 +52,19 @@ u8 tegra_get_platform(void)
>  	return (tegra_read_chipid() >> 20) & 0xf;
>  }
>  
> +bool tegra_is_silicon(void)
> +{
> +	switch (tegra_get_chip_id()) {
> +	case TEGRA194:
> +		if (tegra_get_platform() == 0)
> +			return true;
> +
> +		return false;
> +	}
> +
> +	return false;
> +}
> +

Should we do this the other way around and default to is-silicon?

For devices prior to Tegra194, this will always return false.

Jon
Thierry Reding Sept. 15, 2020, 12:38 p.m. UTC | #2
On Mon, Sep 07, 2020 at 08:32:08PM +0100, Jon Hunter wrote:
> 
> On 16/07/2020 15:18, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > This function can be used by drivers to determine whether code is
> > running on silicon or on a simulation platform.
> > 
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  drivers/soc/tegra/fuse/tegra-apbmisc.c | 13 +++++++++++++
> >  include/soc/tegra/fuse.h               |  1 +
> >  2 files changed, 14 insertions(+)
> > 
> > diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c
> > index 89f1479b4d0e..be6b7fc169ca 100644
> > --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
> > +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
> > @@ -52,6 +52,19 @@ u8 tegra_get_platform(void)
> >  	return (tegra_read_chipid() >> 20) & 0xf;
> >  }
> >  
> > +bool tegra_is_silicon(void)
> > +{
> > +	switch (tegra_get_chip_id()) {
> > +	case TEGRA194:
> > +		if (tegra_get_platform() == 0)
> > +			return true;
> > +
> > +		return false;
> > +	}
> > +
> > +	return false;
> > +}
> > +
> 
> Should we do this the other way around and default to is-silicon?
> 
> For devices prior to Tegra194, this will always return false.

Yes, that's definitely a bug. I'll address that in the next version.

Thierry
diff mbox series

Patch

diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c
index 89f1479b4d0e..be6b7fc169ca 100644
--- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
+++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
@@ -52,6 +52,19 @@  u8 tegra_get_platform(void)
 	return (tegra_read_chipid() >> 20) & 0xf;
 }
 
+bool tegra_is_silicon(void)
+{
+	switch (tegra_get_chip_id()) {
+	case TEGRA194:
+		if (tegra_get_platform() == 0)
+			return true;
+
+		return false;
+	}
+
+	return false;
+}
+
 u32 tegra_read_straps(void)
 {
 	WARN(!chipid, "Tegra ABP MISC not yet available\n");
diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index 214908fc5581..a9db917a1d06 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -24,6 +24,7 @@ 
 u32 tegra_read_chipid(void);
 u8 tegra_get_chip_id(void);
 u8 tegra_get_platform(void);
+bool tegra_is_silicon(void);
 
 enum tegra_revision {
 	TEGRA_REVISION_UNKNOWN = 0,