Commit b5df0b2e authored by Tomer Maimon's avatar Tomer Maimon Committed by Mark Brown

spi: npcm-pspi: modify reset support

Modify NPCM perphiral SPI reset support from
direct register access to reset controller support.
Signed-off-by: default avatarTomer Maimon <tmaimon77@gmail.com>
Link: https://lore.kernel.org/r/20200115162301.235926-5-tmaimon77@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent b4adf5b2
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/reset.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
...@@ -20,7 +21,7 @@ ...@@ -20,7 +21,7 @@
struct npcm_pspi { struct npcm_pspi {
struct completion xfer_done; struct completion xfer_done;
struct regmap *rst_regmap; struct reset_control *reset;
struct spi_master *master; struct spi_master *master;
unsigned int tx_bytes; unsigned int tx_bytes;
unsigned int rx_bytes; unsigned int rx_bytes;
...@@ -59,12 +60,6 @@ struct npcm_pspi { ...@@ -59,12 +60,6 @@ struct npcm_pspi {
#define NPCM_PSPI_MIN_CLK_DIVIDER 4 #define NPCM_PSPI_MIN_CLK_DIVIDER 4
#define NPCM_PSPI_DEFAULT_CLK 25000000 #define NPCM_PSPI_DEFAULT_CLK 25000000
/* reset register */
#define NPCM7XX_IPSRST2_OFFSET 0x24
#define NPCM7XX_PSPI1_RESET BIT(22)
#define NPCM7XX_PSPI2_RESET BIT(23)
static inline unsigned int bytes_per_word(unsigned int bits) static inline unsigned int bytes_per_word(unsigned int bits)
{ {
return bits <= 8 ? 1 : 2; return bits <= 8 ? 1 : 2;
...@@ -292,9 +287,9 @@ static int npcm_pspi_unprepare_transfer_hardware(struct spi_master *master) ...@@ -292,9 +287,9 @@ static int npcm_pspi_unprepare_transfer_hardware(struct spi_master *master)
static void npcm_pspi_reset_hw(struct npcm_pspi *priv) static void npcm_pspi_reset_hw(struct npcm_pspi *priv)
{ {
regmap_write(priv->rst_regmap, NPCM7XX_IPSRST2_OFFSET, reset_control_assert(priv->reset);
NPCM7XX_PSPI1_RESET << priv->id); udelay(5);
regmap_write(priv->rst_regmap, NPCM7XX_IPSRST2_OFFSET, 0x0); reset_control_deassert(priv->reset);
} }
static irqreturn_t npcm_pspi_handler(int irq, void *dev_id) static irqreturn_t npcm_pspi_handler(int irq, void *dev_id)
...@@ -358,10 +353,6 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -358,10 +353,6 @@ static int npcm_pspi_probe(struct platform_device *pdev)
if (num_cs < 0) if (num_cs < 0)
return num_cs; return num_cs;
pdev->id = of_alias_get_id(np, "spi");
if (pdev->id < 0)
pdev->id = 0;
master = spi_alloc_master(&pdev->dev, sizeof(*priv)); master = spi_alloc_master(&pdev->dev, sizeof(*priv));
if (!master) if (!master)
return -ENOMEM; return -ENOMEM;
...@@ -371,7 +362,6 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -371,7 +362,6 @@ static int npcm_pspi_probe(struct platform_device *pdev)
priv = spi_master_get_devdata(master); priv = spi_master_get_devdata(master);
priv->master = master; priv->master = master;
priv->is_save_param = false; priv->is_save_param = false;
priv->id = pdev->id;
priv->base = devm_platform_ioremap_resource(pdev, 0); priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base)) { if (IS_ERR(priv->base)) {
...@@ -396,11 +386,10 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -396,11 +386,10 @@ static int npcm_pspi_probe(struct platform_device *pdev)
goto out_disable_clk; goto out_disable_clk;
} }
priv->rst_regmap = priv->reset = devm_reset_control_get(&pdev->dev, NULL);
syscon_regmap_lookup_by_compatible("nuvoton,npcm750-rst"); if (IS_ERR(priv->reset)) {
if (IS_ERR(priv->rst_regmap)) { ret = PTR_ERR(priv->reset);
dev_err(&pdev->dev, "failed to find nuvoton,npcm750-rst\n"); goto out_disable_clk;
return PTR_ERR(priv->rst_regmap);
} }
/* reset SPI-HW block */ /* reset SPI-HW block */
...@@ -421,7 +410,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -421,7 +410,7 @@ static int npcm_pspi_probe(struct platform_device *pdev)
master->min_speed_hz = DIV_ROUND_UP(clk_hz, NPCM_PSPI_MAX_CLK_DIVIDER); master->min_speed_hz = DIV_ROUND_UP(clk_hz, NPCM_PSPI_MAX_CLK_DIVIDER);
master->mode_bits = SPI_CPHA | SPI_CPOL; master->mode_bits = SPI_CPHA | SPI_CPOL;
master->dev.of_node = pdev->dev.of_node; master->dev.of_node = pdev->dev.of_node;
master->bus_num = pdev->id; master->bus_num = -1;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->transfer_one = npcm_pspi_transfer_one; master->transfer_one = npcm_pspi_transfer_one;
master->prepare_transfer_hardware = master->prepare_transfer_hardware =
...@@ -454,7 +443,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -454,7 +443,7 @@ static int npcm_pspi_probe(struct platform_device *pdev)
if (ret) if (ret)
goto out_disable_clk; goto out_disable_clk;
pr_info("NPCM Peripheral SPI %d probed\n", pdev->id); pr_info("NPCM Peripheral SPI %d probed\n", master->bus_num);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment