Skip to content

Commit

Permalink
spi: npcm-fiu: add Arbel NPCM8XX support
Browse files Browse the repository at this point in the history
Merge series from Tomer Maimon <tmaimon77@gmail.com>:

This patch set adds Arbel NPCM8XX Flash Interface Unit (FIU) support to FIU NPCM
driver and modify direct read dummy configuration.

NPCM8XX FIU supports four controllers.

The NPCM FIU driver tested on NPCM845 evaluation board.
  • Loading branch information
Mark Brown committed Jul 20, 2022
2 parents ee91231 + 650b014 commit 23089eb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
13 changes: 12 additions & 1 deletion Documentation/devicetree/bindings/spi/nuvoton,npcm-fiu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ The NPCM7XX supports three FIU modules,
FIU0 and FIUx supports two chip selects,
FIU3 support four chip select.

The NPCM8XX supports four FIU modules,
FIU0 and FIUx supports two chip selects,
FIU1 and FIU3 supports four chip selects.

Required properties:
- compatible : "nuvoton,npcm750-fiu" for the NPCM7XX BMC
- compatible : "nuvoton,npcm750-fiu" for Poleg NPCM7XX BMC
"nuvoton,npcm845-fiu" for Arbel NPCM8XX BMC
- #address-cells : should be 1.
- #size-cells : should be 0.
- reg : the first contains the register location and length,
Expand All @@ -30,6 +35,12 @@ Aliases:
fiu1 represent fiu 3 controller
fiu2 represent fiu x controller

In the NPCM8XX BMC:
fiu0 represent fiu 0 controller
fiu1 represent fiu 1 controller
fiu2 represent fiu 3 controller
fiu3 represent fiu x controller

Example:
fiu3: spi@c00000000 {
compatible = "nuvoton,npcm750-fiu";
Expand Down
28 changes: 26 additions & 2 deletions drivers/spi/spi-npcm-fiu.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#define NPCM_FIU_UMA_DR1 0x34
#define NPCM_FIU_UMA_DR2 0x38
#define NPCM_FIU_UMA_DR3 0x3C
#define NPCM_FIU_CFG 0x78
#define NPCM_FIU_MAX_REG_LIMIT 0x80

/* FIU Direct Read Configuration Register */
Expand Down Expand Up @@ -151,6 +152,9 @@
#define NPCM_FIU_UMA_DR3_RB13 GENMASK(15, 8)
#define NPCM_FIU_UMA_DR3_RB12 GENMASK(7, 0)

/* FIU Configuration Register */
#define NPCM_FIU_CFG_FIU_FIX BIT(31)

/* FIU Read Mode */
enum {
DRD_SINGLE_WIRE_MODE = 0,
Expand Down Expand Up @@ -187,6 +191,7 @@ enum {
FIU0 = 0,
FIU3,
FIUX,
FIU1,
};

struct npcm_fiu_info {
Expand Down Expand Up @@ -214,6 +219,21 @@ static const struct fiu_data npcm7xx_fiu_data = {
.fiu_max = 3,
};

static const struct npcm_fiu_info npxm8xx_fiu_info[] = {
{.name = "FIU0", .fiu_id = FIU0,
.max_map_size = MAP_SIZE_128MB, .max_cs = 2},
{.name = "FIU3", .fiu_id = FIU3,
.max_map_size = MAP_SIZE_128MB, .max_cs = 4},
{.name = "FIUX", .fiu_id = FIUX,
.max_map_size = MAP_SIZE_16MB, .max_cs = 2},
{.name = "FIU1", .fiu_id = FIU1,
.max_map_size = MAP_SIZE_16MB, .max_cs = 4} };

static const struct fiu_data npxm8xx_fiu_data = {
.npcm_fiu_data_info = npxm8xx_fiu_info,
.fiu_max = 4,
};

struct npcm_fiu_spi;

struct npcm_fiu_chip {
Expand Down Expand Up @@ -252,8 +272,7 @@ static void npcm_fiu_set_drd(struct npcm_fiu_spi *fiu,
fiu->drd_op.addr.buswidth = op->addr.buswidth;
regmap_update_bits(fiu->regmap, NPCM_FIU_DRD_CFG,
NPCM_FIU_DRD_CFG_DBW,
((op->dummy.nbytes * ilog2(op->addr.buswidth)) / BITS_PER_BYTE)
<< NPCM_FIU_DRD_DBW_SHIFT);
op->dummy.nbytes << NPCM_FIU_DRD_DBW_SHIFT);
fiu->drd_op.dummy.nbytes = op->dummy.nbytes;
regmap_update_bits(fiu->regmap, NPCM_FIU_DRD_CFG,
NPCM_FIU_DRD_CFG_RDCMD, op->cmd.opcode);
Expand Down Expand Up @@ -625,6 +644,10 @@ static int npcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc)
regmap_update_bits(gcr_regmap, NPCM7XX_INTCR3_OFFSET,
NPCM7XX_INTCR3_FIU_FIX,
NPCM7XX_INTCR3_FIU_FIX);
} else {
regmap_update_bits(fiu->regmap, NPCM_FIU_CFG,
NPCM_FIU_CFG_FIU_FIX,
NPCM_FIU_CFG_FIU_FIX);
}

if (desc->info.op_tmpl.data.dir == SPI_MEM_DATA_IN) {
Expand Down Expand Up @@ -665,6 +688,7 @@ static const struct spi_controller_mem_ops npcm_fiu_mem_ops = {

static const struct of_device_id npcm_fiu_dt_ids[] = {
{ .compatible = "nuvoton,npcm750-fiu", .data = &npcm7xx_fiu_data },
{ .compatible = "nuvoton,npcm845-fiu", .data = &npxm8xx_fiu_data },
{ /* sentinel */ }
};

Expand Down

0 comments on commit 23089eb

Please sign in to comment.