From: Raag Jadav <raag.jadav@intel.com>
To: Alexander Usyskin <alexander.usyskin@intel.com>
Cc: "Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Karthik Poosa" <karthik.poosa@intel.com>,
"Reuven Abliyev" <reuven.abliyev@intel.com>,
"Oren Weil" <oren.jer.weil@intel.com>,
linux-mtd@lists.infradead.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
linux-kernel@vger.kernel.org, "Tomas Winkler" <tomasw@gmail.com>
Subject: Re: [PATCH v9 03/12] mtd: intel-dg: implement region enumeration
Date: Tue, 29 Apr 2025 12:44:13 +0300 [thread overview]
Message-ID: <aBCfbaYs9CnXL2h1@black.fi.intel.com> (raw)
In-Reply-To: <20250424132536.3043825-4-alexander.usyskin@intel.com>
On Thu, Apr 24, 2025 at 04:25:27PM +0300, Alexander Usyskin wrote:
> In intel-dg, there is no access to the spi controller,
> the information is extracted from the descriptor region.
...
> @@ -22,9 +24,199 @@ struct intel_dg_nvm {
> u8 id;
> u64 offset;
> u64 size;
> + unsigned int is_readable:1;
> + unsigned int is_writable:1;
> } regions[] __counted_by(nregions);
> };
>
> +#define NVM_TRIGGER_REG 0x00000000
> +#define NVM_VALSIG_REG 0x00000010
> +#define NVM_ADDRESS_REG 0x00000040
> +#define NVM_REGION_ID_REG 0x00000044
> +/*
> + * [15:0]-Erase size = 0x0010 4K 0x0080 32K 0x0100 64K
> + * [23:16]-Reserved
> + * [31:24]-Erase MEM RegionID
> + */
> +#define NVM_ERASE_REG 0x00000048
> +#define NVM_ACCESS_ERROR_REG 0x00000070
> +#define NVM_ADDRESS_ERROR_REG 0x00000074
> +
> +/* Flash Valid Signature */
> +#define NVM_FLVALSIG 0x0FF0A55A
> +
> +#define NVM_MAP_ADDR_MASK GENMASK(7, 0)
> +#define NVM_MAP_ADDR_SHIFT 0x00000004
> +
> +#define NVM_REGION_ID_DESCRIPTOR 0
> +/* Flash Region Base Address */
> +#define NVM_FRBA 0x40
> +/* Flash Region __n - Flash Descriptor Record */
> +#define NVM_FLREG(__n) (NVM_FRBA + ((__n) * 4))
> +/* Flash Map 1 Register */
> +#define NVM_FLMAP1_REG 0x18
> +#define NVM_FLMSTR4_OFFSET 0x00C
> +
> +#define NVM_ACCESS_ERROR_PCIE_MASK 0x7
> +
> +#define NVM_FREG_BASE_MASK GENMASK(15, 0)
> +#define NVM_FREG_ADDR_MASK GENMASK(31, 16)
> +#define NVM_FREG_ADDR_SHIFT 12
> +#define NVM_FREG_MIN_REGION_SIZE 0xFFF
Should we move these to a header?
> +static inline void idg_nvm_set_region_id(struct intel_dg_nvm *nvm, u8 region)
> +{
> + iowrite32((u32)region, nvm->base + NVM_REGION_ID_REG);
> +}
> +
> +static inline u32 idg_nvm_error(struct intel_dg_nvm *nvm)
> +{
> + void __iomem *base = nvm->base;
> +
> + u32 reg = ioread32(base + NVM_ACCESS_ERROR_REG) & NVM_ACCESS_ERROR_PCIE_MASK;
> +
> + /* reset error bits */
> + if (reg)
> + iowrite32(reg, base + NVM_ACCESS_ERROR_REG);
> +
> + return reg;
> +}
> +
> +static inline u32 idg_nvm_read32(struct intel_dg_nvm *nvm, u32 address)
> +{
> + void __iomem *base = nvm->base;
> +
> + iowrite32(address, base + NVM_ADDRESS_REG);
> +
> + return ioread32(base + NVM_TRIGGER_REG);
> +}
> +
> +static int idg_nvm_get_access_map(struct intel_dg_nvm *nvm, u32 *access_map)
> +{
> + u32 flmap1;
> + u32 fmba;
> + u32 fmstr4;
> + u32 fmstr4_addr;
Nit: These are in order of appearance vs reverse xmas tree in other places.
Perhaps make them consistent?
> + idg_nvm_set_region_id(nvm, NVM_REGION_ID_DESCRIPTOR);
> +
> + flmap1 = idg_nvm_read32(nvm, NVM_FLMAP1_REG);
> + if (idg_nvm_error(nvm))
> + return -EIO;
> + /* Get Flash Master Baser Address (FMBA) */
> + fmba = (FIELD_GET(NVM_MAP_ADDR_MASK, flmap1) << NVM_MAP_ADDR_SHIFT);
> + fmstr4_addr = fmba + NVM_FLMSTR4_OFFSET;
> +
> + fmstr4 = idg_nvm_read32(nvm, fmstr4_addr);
> + if (idg_nvm_error(nvm))
> + return -EIO;
> +
> + *access_map = fmstr4;
> + return 0;
> +}
> +
> +static bool idg_nvm_region_readable(u32 access_map, u8 region)
> +{
> + if (region < 12)
Anything special about 12? Should it have a macro def somewhere?
> + return access_map & BIT(region + 8); /* [19:8] */
> + else
> + return access_map & BIT(region - 12); /* [3:0] */
> +}
> +
> +static bool idg_nvm_region_writable(u32 access_map, u8 region)
> +{
> + if (region < 12)
Ditto.
> + return access_map & BIT(region + 20); /* [31:20] */
> + else
> + return access_map & BIT(region - 8); /* [7:4] */
> +}
Raag
WARNING: multiple messages have this Message-ID (diff)
From: Raag Jadav <raag.jadav@intel.com>
To: Alexander Usyskin <alexander.usyskin@intel.com>
Cc: "Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Karthik Poosa" <karthik.poosa@intel.com>,
"Reuven Abliyev" <reuven.abliyev@intel.com>,
"Oren Weil" <oren.jer.weil@intel.com>,
linux-mtd@lists.infradead.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
linux-kernel@vger.kernel.org, "Tomas Winkler" <tomasw@gmail.com>
Subject: Re: [PATCH v9 03/12] mtd: intel-dg: implement region enumeration
Date: Tue, 29 Apr 2025 12:44:13 +0300 [thread overview]
Message-ID: <aBCfbaYs9CnXL2h1@black.fi.intel.com> (raw)
In-Reply-To: <20250424132536.3043825-4-alexander.usyskin@intel.com>
On Thu, Apr 24, 2025 at 04:25:27PM +0300, Alexander Usyskin wrote:
> In intel-dg, there is no access to the spi controller,
> the information is extracted from the descriptor region.
...
> @@ -22,9 +24,199 @@ struct intel_dg_nvm {
> u8 id;
> u64 offset;
> u64 size;
> + unsigned int is_readable:1;
> + unsigned int is_writable:1;
> } regions[] __counted_by(nregions);
> };
>
> +#define NVM_TRIGGER_REG 0x00000000
> +#define NVM_VALSIG_REG 0x00000010
> +#define NVM_ADDRESS_REG 0x00000040
> +#define NVM_REGION_ID_REG 0x00000044
> +/*
> + * [15:0]-Erase size = 0x0010 4K 0x0080 32K 0x0100 64K
> + * [23:16]-Reserved
> + * [31:24]-Erase MEM RegionID
> + */
> +#define NVM_ERASE_REG 0x00000048
> +#define NVM_ACCESS_ERROR_REG 0x00000070
> +#define NVM_ADDRESS_ERROR_REG 0x00000074
> +
> +/* Flash Valid Signature */
> +#define NVM_FLVALSIG 0x0FF0A55A
> +
> +#define NVM_MAP_ADDR_MASK GENMASK(7, 0)
> +#define NVM_MAP_ADDR_SHIFT 0x00000004
> +
> +#define NVM_REGION_ID_DESCRIPTOR 0
> +/* Flash Region Base Address */
> +#define NVM_FRBA 0x40
> +/* Flash Region __n - Flash Descriptor Record */
> +#define NVM_FLREG(__n) (NVM_FRBA + ((__n) * 4))
> +/* Flash Map 1 Register */
> +#define NVM_FLMAP1_REG 0x18
> +#define NVM_FLMSTR4_OFFSET 0x00C
> +
> +#define NVM_ACCESS_ERROR_PCIE_MASK 0x7
> +
> +#define NVM_FREG_BASE_MASK GENMASK(15, 0)
> +#define NVM_FREG_ADDR_MASK GENMASK(31, 16)
> +#define NVM_FREG_ADDR_SHIFT 12
> +#define NVM_FREG_MIN_REGION_SIZE 0xFFF
Should we move these to a header?
> +static inline void idg_nvm_set_region_id(struct intel_dg_nvm *nvm, u8 region)
> +{
> + iowrite32((u32)region, nvm->base + NVM_REGION_ID_REG);
> +}
> +
> +static inline u32 idg_nvm_error(struct intel_dg_nvm *nvm)
> +{
> + void __iomem *base = nvm->base;
> +
> + u32 reg = ioread32(base + NVM_ACCESS_ERROR_REG) & NVM_ACCESS_ERROR_PCIE_MASK;
> +
> + /* reset error bits */
> + if (reg)
> + iowrite32(reg, base + NVM_ACCESS_ERROR_REG);
> +
> + return reg;
> +}
> +
> +static inline u32 idg_nvm_read32(struct intel_dg_nvm *nvm, u32 address)
> +{
> + void __iomem *base = nvm->base;
> +
> + iowrite32(address, base + NVM_ADDRESS_REG);
> +
> + return ioread32(base + NVM_TRIGGER_REG);
> +}
> +
> +static int idg_nvm_get_access_map(struct intel_dg_nvm *nvm, u32 *access_map)
> +{
> + u32 flmap1;
> + u32 fmba;
> + u32 fmstr4;
> + u32 fmstr4_addr;
Nit: These are in order of appearance vs reverse xmas tree in other places.
Perhaps make them consistent?
> + idg_nvm_set_region_id(nvm, NVM_REGION_ID_DESCRIPTOR);
> +
> + flmap1 = idg_nvm_read32(nvm, NVM_FLMAP1_REG);
> + if (idg_nvm_error(nvm))
> + return -EIO;
> + /* Get Flash Master Baser Address (FMBA) */
> + fmba = (FIELD_GET(NVM_MAP_ADDR_MASK, flmap1) << NVM_MAP_ADDR_SHIFT);
> + fmstr4_addr = fmba + NVM_FLMSTR4_OFFSET;
> +
> + fmstr4 = idg_nvm_read32(nvm, fmstr4_addr);
> + if (idg_nvm_error(nvm))
> + return -EIO;
> +
> + *access_map = fmstr4;
> + return 0;
> +}
> +
> +static bool idg_nvm_region_readable(u32 access_map, u8 region)
> +{
> + if (region < 12)
Anything special about 12? Should it have a macro def somewhere?
> + return access_map & BIT(region + 8); /* [19:8] */
> + else
> + return access_map & BIT(region - 12); /* [3:0] */
> +}
> +
> +static bool idg_nvm_region_writable(u32 access_map, u8 region)
> +{
> + if (region < 12)
Ditto.
> + return access_map & BIT(region + 20); /* [31:20] */
> + else
> + return access_map & BIT(region - 8); /* [7:4] */
> +}
Raag
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2025-04-29 9:44 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 13:25 [PATCH v9 00/12] mtd: add driver for Intel discrete graphics Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 01/12] mtd: core: always create master device Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 02/12] mtd: add driver for intel graphics non-volatile memory device Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-29 9:31 ` Raag Jadav
2025-04-29 9:31 ` Raag Jadav
2025-05-15 10:11 ` Usyskin, Alexander
2025-05-15 10:11 ` Usyskin, Alexander
2025-05-15 12:13 ` Raag Jadav
2025-05-15 12:13 ` Raag Jadav
2025-04-24 13:25 ` [PATCH v9 03/12] mtd: intel-dg: implement region enumeration Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-29 9:44 ` Raag Jadav [this message]
2025-04-29 9:44 ` Raag Jadav
2025-05-15 11:23 ` Usyskin, Alexander
2025-05-15 11:23 ` Usyskin, Alexander
2025-05-15 12:19 ` Raag Jadav
2025-05-15 12:19 ` Raag Jadav
2025-05-15 13:07 ` Usyskin, Alexander
2025-05-15 13:07 ` Usyskin, Alexander
2025-04-24 13:25 ` [PATCH v9 04/12] mtd: intel-dg: implement access functions Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 05/12] mtd: intel-dg: register with mtd Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 06/12] mtd: intel-dg: align 64bit read and write Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 07/12] mtd: intel-dg: wake card on operations Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 08/12] drm/i915/nvm: add nvm device for discrete graphics Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 09/12] drm/i915/nvm: add support for access mode Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 10/12] drm/xe/nvm: add on-die non-volatile memory device Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 11/12] drm/xe/nvm: add support for access mode Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 12/12] drm/xe/nvm: add support for non-posted erase Alexander Usyskin
2025-04-24 13:25 ` Alexander Usyskin
2025-04-24 14:21 ` ✗ Fi.CI.CHECKPATCH: warning for mtd: add driver for Intel discrete graphics (rev10) Patchwork
2025-04-24 14:21 ` ✗ Fi.CI.SPARSE: " Patchwork
2025-04-24 14:42 ` ✓ i915.CI.BAT: success " Patchwork
2025-04-24 17:52 ` ✓ CI.Patch_applied: success for mtd: add driver for Intel discrete graphics (rev2) Patchwork
2025-04-24 17:52 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-24 17:54 ` ✓ CI.KUnit: success " Patchwork
2025-04-24 18:02 ` ✓ CI.Build: " Patchwork
2025-04-24 18:04 ` ✗ CI.Hooks: failure " Patchwork
2025-04-24 18:06 ` ✗ CI.checksparse: warning " Patchwork
2025-04-24 18:30 ` ✓ Xe.CI.BAT: success " Patchwork
2025-04-24 23:58 ` ✗ i915.CI.Full: failure for mtd: add driver for Intel discrete graphics (rev10) Patchwork
2025-04-25 15:25 ` ✗ Xe.CI.Full: failure for mtd: add driver for Intel discrete graphics (rev2) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aBCfbaYs9CnXL2h1@black.fi.intel.com \
--to=raag.jadav@intel.com \
--cc=airlied@gmail.com \
--cc=alexander.usyskin@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=karthik.poosa@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lucas.demarchi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=oren.jer.weil@intel.com \
--cc=reuven.abliyev@intel.com \
--cc=richard@nod.at \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tomasw@gmail.com \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.