Add NPCM7xx patches to dev-5.8
Subsystems (8)
Tomer Maimon
maintainerPATCH v2 8/11 pinctrl: npcm7xx: Add pin persist configuration support
In reply to Tomer Maimon--- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+)
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +65 -0
@@ -36,6 +36,19 @@#define SRCNT_ESPI BIT(3) +/* reset registers */ +#define NPCM7XX_RST_WD0RCR 0x38 +#define NPCM7XX_RST_WD1RCR 0x3C +#define NPCM7XX_RST_WD2RCR 0x40 +#define NPCM7XX_RST_SWRSTC1 0x44 +#define NPCM7XX_RST_SWRSTC2 0x48 +#define NPCM7XX_RST_SWRSTC3 0x4C +#define NPCM7XX_RST_SWRSTC4 0x50 +#define NPCM7XX_RST_CORSTC 0x5C + +#define GPIOX_MODULE_RESET BIT(16) +#define CA9C_MODULE_RESET BIT(0) +/* GPIO registers */ #define NPCM7XX_GP_N_TLOCK1 0x00#define NPCM7XX_GP_N_DIN 0x04/* Data IN */
@@ -94,6 +107,7 @@ struct npcm7xx_pinctrl {struct npcm7xx_gpio gpio_bank[NPCM7XX_GPIO_BANK_NUM ];struct irq_domain *domain;struct regmap *gcr_regmap; +struct regmap *rst_regmap;void __iomem *regs;u32 bank_num; };
@@ -1583,6 +1597,48 @@ static int npcm7xx_set_drive_strength(struct npcm7xx_pinctrl *npcm,return -ENOTSUPP ; } +static int npcm7xx_gpio_reset_persist (struct npcm7xx_pinctrl *npcm, +unsigned int pin,int enable) +{ +struct npcm7xx_gpio *bank = + &npcm->gpio_bank[pin /NPCM7XX_GPIO_PER_BANK ]; +int banknum = pin / bank->gc.ngpio; + +if (enable) { +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_WD0RCR , +GPIOX_MODULE_RESET << banknum,0 ); +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_WD1RCR , +GPIOX_MODULE_RESET << banknum,0 ); +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_WD2RCR , +GPIOX_MODULE_RESET << banknum,0 ); +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_CORSTC , +GPIOX_MODULE_RESET << banknum,0 ); + }else { +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_WD0RCR , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET ); +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_WD1RCR , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET ); +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_WD2RCR , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET ); +regmap_update_bits (npcm->rst_regmap,NPCM7XX_RST_CORSTC , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET , + (GPIOX_MODULE_RESET << banknum) | +CA9C_MODULE_RESET ); + } + +return 0 ; +} +/* pinctrl_ops */ static void npcm7xx_pin_dbg_show (struct pinctrl_dev *pctldev,struct seq_file *s,unsigned int offset)
@@ -1852,6 +1908,8 @@ static int npcm7xx_config_set_one(struct npcm7xx_pinctrl *npcm,return npcm7xx_set_slew_rate (bank, npcm->gcr_regmap, pin, arg);case PIN_CONFIG_DRIVE_STRENGTH :return npcm7xx_set_drive_strength (npcm, pin, arg); +case PIN_CONFIG_PERSIST_STATE : +return npcm7xx_gpio_reset_persist (npcm, pin, arg);default :return -ENOTSUPP ; }
@@ -2051,6 +2109,13 @@ static int npcm7xx_pinctrl_probe(struct platform_device *pdev)return PTR_ERR (pctrl->gcr_regmap); } + pctrl->rst_regmap = +syscon_regmap_lookup_by_compatible ("nuvoton,npcm750-rst" ); +if (IS_ERR (pctrl->rst_regmap)) { +dev_err (pctrl->dev,"didn't find nuvoton,npcm750-rst\n" ); +return PTR_ERR (pctrl->rst_regmap); + } + ret =npcm7xx_gpio_of (pctrl);if (ret <0 ) {dev_err (pctrl->dev,"Failed to gpio dt-binding %u\n" , ret);
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 3/11 dts: npcm750: add fuse regmap support node
In reply to Tomer Maimon--- arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi +6 -0
@@ -82,6 +82,12 @@ "simple-mfd"; reg = <0x801000 0x6C>; }; + + fuse:fuse@18a000 { + compatible = "nuvoton,npcm750-fuse", "syscon", + "simple-mfd"; + reg = <0x18a000 0x1000>; + }; scu: scu@3fe000 { compatible = "arm,cortex-a9-scu";
Signature · 1 line
2.22.0
Tomer Maimon
maintainerv2 cover Add NPCM7xx patches to dev-5.8
In this patch set we will like to align with relevant modifications in Nuvoton OpenBMC Linux kernel 5.4.
Linux upstream current status:
1. npcm7xx clock driver - adding read only
flag to divider clocks, Will be sent to Linux community.
2. Adding NPCM ADC calibration - Will be sent to Linux vanilla, but I am not sure it will be approved.
3. Add DT restart priority and reset type support - sent to Linux community la but havent approved yet.
4. persist configuration to the pin control driver - asked by a costumer, didnt sent to Linux community.
5. Add HGPIO pin support to NPCM7xx pinctrl driver - will be sent to Linux community
6. JTAG master driver - will be sent to Linux community once we will have BMC folder.
Changes since version 1:
- Address comments from Jonathan Neuschäfer: removing trailing whitespace in NPCM watchdog documentation.
- Adding Stanley Chu to NPCM JTAG master driver
Tomer Maimon (11):
clk: npcm7xx: add read only flag to divider clocks
iio: adc: add calibration support to npcm ADC
dts: npcm750: add fuse regmap support node
watchdog: npcm: Add DT restart priority and reset type support
dt-binding: watchdog: Add DT restart priority and reset type
pinctrl: npcm7xx: Add HGPIO pin support to NPCM7xx pinctrl driver
pinctrl: pinconf: add pin persist configuration
pinctrl: npcm7xx: Add pin persist configuration support
spi: npcm-pspi: Add full duplex support
dt-binding: bmc: add NPCM7XX JTAG master documentation
misc: npcm7xx-jtag-master: add NPCM7xx JTAG master driver
.../bindings/bmc/npcm7xx-jtag-master.txt | 38 + .../bindings/watchdog/nuvoton,npcm-wdt.txt | 32 + arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi | 6 + drivers/clk/clk-npcm7xx.c | 70 +- drivers/iio/adc/npcm_adc.c | 191 ++++ drivers/misc/Kconfig | 6 + drivers/misc/Makefile | 1 + drivers/misc/npcm7xx-jtag-master.c | 840 ++++++++++++++++++ drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 130 ++- drivers/pinctrl/pinconf-generic.c | 3 + drivers/spi/spi-npcm-pspi.c | 75 +- drivers/watchdog/npcm_wdt.c | 121 ++- 12 files changed, 1418 insertions(+), 95 deletions(-) create mode 100644 Documentation/devicetree/bindings/bmc/npcm7xx-jtag-master.txt create mode 100644 drivers/misc/npcm7xx-jtag-master.c
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 5/11 dt-binding: watchdog: Add DT restart priority and reset type
Add device tree restart priority documentation and three reset types documentation.
--- .../bindings/watchdog/nuvoton,npcm-wdt.txt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+)
Documentation/devicetree/bindings/watchdog/nuvoton,npcm-wdt.txt +32 -0
@@ -17,6 +17,34 @@ Required clocking property, have to be one of: Optional properties: - timeout-sec : Contains the watchdog timeout in seconds +- nuvoton,restart-priority - Contains the card restart priority. +- nuvoton,card-reset-type = "porst|corst|wd0|wd1|wd2|sw1|sw2|sw3|sw4" + Contains the card reset type for checking and indicating + the last card reset status (WDIOF_CARDRESET) + + If 'nuvoton,card-reset-type' is not specified the default is porst + + Reset types: + - porst: Power reset + - corst: Core reset + - wdX : Watchdog reset X (X represante 0-2) + - swX : Software reset X (X represante 1-4) + +- nuvoton,ext1-reset-type = "porst|corst|wd0|wd1|wd2|sw1|sw2|sw3|sw4" + Contains the external 2 reset type for checking and indicating + the last external 2 reset status (WDIOF_EXTERN1) + + If 'nuvoton,card-reset-type' is not specified the default is wd0. + + Reset types are the same as in nuvoton,card-reset-type property. + +- nuvoton,ext2-reset-type = "porst|corst|wd0|wd1|wd2|sw1|sw2|sw3|sw4" + Contains the external 2 reset type for checking and indicating + the last external 2 reset status (WDIOF_EXTERN2) + + If 'nuvoton,card-reset-type' is not specified the default is sw1. + + Reset types are the same as in nuvoton,card-reset-type property. Example:
@@ -25,4 +53,8 @@ timer@f000801c { interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>; reg = <0xf000801c 0x4>; clocks = <&clk NPCM7XX_CLK_TIMER>; + nuvoton,restart-priority = <155>; + nuvoton,card-reset-type = "porst"; + nuvoton,ext1-reset-type = "wd1"; + nuvoton,ext2-reset-type = "sw2"; };
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 2/11 iio: adc: add calibration support to npcm ADC
In reply to Tomer MaimonAdd calibration to improve accuracy measurement when using internal referance voltage.
the calibration values taken from the FUSE module.
--- drivers/iio/adc/npcm_adc.c | 191 +++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+)
drivers/iio/adc/npcm_adc.c +191 -0
@@ -17,6 +17,8 @@#include <linux/reset.h> struct npcm_adc { +u32 R05; +u32 R15;bool int_status;u32 adc_sample_hz;struct device *dev;
@@ -51,6 +53,40 @@ struct npcm_adc {#define NPCM_RESOLUTION_BITS 10#define NPCM_INT_VREF_MV 2000 +/* FUSE registers */ +#define NPCM7XX_FST 0x00 +#define NPCM7XX_FADDR 0x04 +#define NPCM7XX_FDATA 0x08 +#define NPCM7XX_FCFG 0x0C +#define NPCM7XX_FCTL 0x14 + +/* FST Register Bits */ +#define NPCM7XX_FST_RDY BIT(0) +#define NPCM7XX_FST_RDST BIT(1) + +/* FADDR Register Bits */ +#define NPCM7XX_FADDR_BYTEADDR BIT(0) +#define NPCM7XX_FADDR_BYTEADDR_MASK GENMASK(9, 0) + +/* FADDR Register Bits */ +#define NPCM7XX_FDATA_DATA BIT(0) +#define NPCM7XX_FDATA_CLEAN_VALUE BIT(1) +#define NPCM7XX_FDATA_DATA_MASK GENMASK(7, 0) + +/* FCTL Register Bits */ +#define NPCM7XX_FCTL_RDST BIT(1) + +/* ADC Calibration Definition */ +#define NPCM_INT_1500MV 768 +#define NPCM_INT_1000MV 512 +#define NPCM_ADC_MIN_VAL 0 +#define NPCM_ADC_MAX_VAL 1023 + +#define FUSE_CALIB_ADDR 24 +#define FUSE_CALIB_SIZE 8 +#define DATA_CALIB_SIZE 4 +#define FUSE_READ_TIMEOUT 0xDEADBEEF +#define NPCM_ADC_CHAN (ch) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \
@@ -71,6 +107,133 @@ static const struct iio_chan_spec npcm_adc_iio_channels[] = { NPCM_ADC_CHAN(7), }; +static int npcm750_fuse_wait_for_ready (struct regmap *fuse_regmap,u32 timeout) +{ +u32 time = timeout; +u32 fstreg; + +while (--time >1 ) { +regmap_read (fuse_regmap,NPCM7XX_FST , &fstreg); +if (fstreg &NPCM7XX_FST_RDY ) { +regmap_write_bits (fuse_regmap,NPCM7XX_FST , +NPCM7XX_FST_RDST ,NPCM7XX_FST_RDST ); +return 0 ; + } + } + +/* try to clear the status in case it was set */ +regmap_write_bits (fuse_regmap,NPCM7XX_FST ,NPCM7XX_FST_RDST , +NPCM7XX_FST_RDST ); + +return -EINVAL ; +} + +static void npcm750_fuse_read (struct regmap *fuse_regmap,u32 addr,u8 *data) +{ +u32 val; + +npcm750_fuse_wait_for_ready (fuse_regmap,FUSE_READ_TIMEOUT ); + +regmap_write_bits (fuse_regmap,NPCM7XX_FADDR , +NPCM7XX_FADDR_BYTEADDR_MASK , addr); +regmap_read (fuse_regmap,NPCM7XX_FADDR , &val); +regmap_write (fuse_regmap,NPCM7XX_FCTL ,NPCM7XX_FCTL_RDST ); + +npcm750_fuse_wait_for_ready (fuse_regmap,FUSE_READ_TIMEOUT ); +regmap_read (fuse_regmap,NPCM7XX_FDATA , &val); + *data = (u8 )val; + +regmap_write_bits (fuse_regmap,NPCM7XX_FDATA ,NPCM7XX_FDATA_DATA_MASK , +NPCM7XX_FDATA_CLEAN_VALUE ); +} + +static int npcm750_ECC_to_nibble (u8 ECC ,u8 nibble) +{ +u8 nibble_b0 = (nibble >>0 ) &BIT (0 ); +u8 nibble_b1 = (nibble >>1 ) &BIT (0 ); +u8 nibble_b2 = (nibble >>2 ) &BIT (0 ); +u8 nibble_b3 = (nibble >>3 ) &BIT (0 ); +u8 tmp_ECC = nibble; + + tmp_ECC |= (nibble_b0 ^ nibble_b1) <<4 | (nibble_b2 ^ nibble_b3) <<5 | + (nibble_b0 ^ nibble_b2) <<6 | (nibble_b1 ^ nibble_b3) <<7 ; + +if (tmp_ECC !=ECC ) +return -EINVAL ; + +return 0 ; +} + +static int npcm750_ECC_to_byte (u16 ECC ,u8 *Byte) +{ +u8 nibble_L, nibble_H; +u8 ECC_L ,ECC_H ; + +ECC_H =ECC >>8 ; + nibble_H =ECC_H &0x0F ; +ECC_L =ECC >>0 ; + nibble_L =ECC_L &0x0F ; + +if (npcm750_ECC_to_nibble (ECC_H , nibble_H) !=0 || +npcm750_ECC_to_nibble (ECC_L , nibble_L) !=0 ) +return -EINVAL ; + + *Byte = nibble_H <<4 | nibble_L <<0 ; + +return 0 ; +} + +static int npcm750_read_nibble_parity (u8 *block_ECC,u8 *ADC_calib) +{ +int i; +u16 ECC ; + +for (i =0 ; i <DATA_CALIB_SIZE ; i++) { +memcpy (&ECC , block_ECC + (i *2 ),2 ); +if (npcm750_ECC_to_byte (ECC , &ADC_calib[i]) !=0 ) +return -EINVAL ; + } + +return 0 ; +} + +static int npcm750_fuse_calibration_read (struct platform_device *pdev, +struct npcm_adc *info) +{ +struct device_node *np = pdev->dev.of_node; +struct regmap *fuse_regmap; +ssize_t bytes_read =0 ; +u8 read_buf[8 ]; +u32 ADC_calib; +u32 addr =FUSE_CALIB_ADDR ; + +if (of_device_is_compatible (np,"nuvoton,npcm750-adc" )) { + fuse_regmap =syscon_regmap_lookup_by_compatible + ("nuvoton,npcm750-fuse" ); +if (IS_ERR (fuse_regmap)) { +dev_warn (&pdev->dev,"Failed to find nuvoton,npcm750-fuse\n" ); +return PTR_ERR (fuse_regmap); + } + +while (bytes_read <FUSE_CALIB_SIZE ) { +npcm750_fuse_read (fuse_regmap, addr, + &read_buf[bytes_read]); + bytes_read++; + addr++; + } + +if (npcm750_read_nibble_parity (read_buf, (u8 *)&ADC_calib)) { +dev_warn (info->dev,"FUSE Clibration read failed\n" ); +return -EINVAL ; + } + + info->R05 = ADC_calib &0xFFFF ; + info->R15 = ADC_calib >>16 ; + } + +return 0 ; +} +static irqreturn_t npcm_adc_isr (int irq,void *data) {u32 regtemp;
@@ -125,6 +288,29 @@ static int npcm_adc_read(struct npcm_adc *info, int *val, u8 channel)return 0 ; } +static void npcm_adc_calibration (int *val,struct npcm_adc *info) +{ +int mul_val; +int offset_val; + + mul_val =NPCM_INT_1000MV * (*val - info->R15); +if (mul_val <0 ) { + mul_val = mul_val *-1 ; + offset_val =DIV_ROUND_CLOSEST (mul_val, + (info->R15 - info->R05)); + *val =NPCM_INT_1500MV - offset_val; + }else { + offset_val =DIV_ROUND_CLOSEST (mul_val, + (info->R15 - info->R05)); + *val =NPCM_INT_1500MV + offset_val; + } + +if (*val <NPCM_ADC_MIN_VAL ) + *val =NPCM_ADC_MIN_VAL ; +if (*val >NPCM_ADC_MAX_VAL ) + *val =NPCM_ADC_MAX_VAL ; +} +static int npcm_adc_read_raw (struct iio_dev *indio_dev,struct iio_chan_spec const *chan,int *val,int *val2,long mask)
@@ -142,6 +328,10 @@ static int npcm_adc_read_raw(struct iio_dev *indio_dev,dev_err (info->dev,"NPCM ADC read failed\n" );return ret; } + +if ((info->R05 || info->R15) &&IS_ERR (info->vref)) +npcm_adc_calibration (val, info); +return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE :if (!IS_ERR (info->vref)) {
@@ -248,6 +438,7 @@ static int npcm_adc_probe(struct platform_device *pdev) info->regs + NPCM_ADCCON); } +npcm750_fuse_calibration_read (pdev, info);init_waitqueue_head (&info->wq); reg_con =ioread32 (info->regs +NPCM_ADCCON );
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 7/11 pinctrl: pinconf: add pin persist configuration
In reply to Tomer MaimonAdd generic pin persist configuration support.
--- drivers/pinctrl/pinconf-generic.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pinctrl/pinconf-generic.c +3 -0
@@ -50,6 +50,7 @@ static const struct pin_config_item conf_items[] = {PCONFDUMP (PIN_CONFIG_SLEEP_HARDWARE_STATE ,"sleep hardware state" ,NULL , false),PCONFDUMP (PIN_CONFIG_SLEW_RATE ,"slew rate" ,NULL , true),PCONFDUMP (PIN_CONFIG_SKEW_DELAY ,"skew delay" ,NULL , true), + PCONFDUMP(PIN_CONFIG_PERSIST_STATE, "persist state", NULL, false), }; static void pinconf_generic_dump_one(struct pinctrl_dev *pctldev,
@@ -184,6 +185,8 @@ static const struct pinconf_generic_params dt_params[] = { { "sleep-hardware-state", PIN_CONFIG_SLEEP_HARDWARE_STATE, 0 }, { "slew-rate", PIN_CONFIG_SLEW_RATE, 0 }, { "skew-delay", PIN_CONFIG_SKEW_DELAY, 0 }, + { "persist-state", PIN_CONFIG_PERSIST_STATE, 0 }, + { "reset-state", PIN_CONFIG_PERSIST_STATE, 1 }, };/**
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 4/11 watchdog: npcm: Add DT restart priority and reset type support
In reply to Tomer MaimonAdd Device tree restart priority and
three reset types support.
--- drivers/watchdog/npcm_wdt.c | 121 +++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-)
drivers/watchdog/npcm_wdt.c +119 -2
@@ -11,7 +11,24 @@#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/watchdog.h> - +#include <linux/regmap.h> +#include <linux/mfd/syscon.h> + +/* NPCM7xx GCR module */ +#define NPCM7XX_RESSR_OFFSET 0x6C +#define NPCM7XX_INTCR2_OFFSET 0x60 + +#define NPCM7XX_PORST BIT(31) +#define NPCM7XX_CORST BIT(30) +#define NPCM7XX_WD0RST BIT(29) +#define NPCM7XX_WD1RST BIT(24) +#define NPCM7XX_WD2RST BIT(23) +#define NPCM7XX_SWR1RST BIT(28) +#define NPCM7XX_SWR2RST BIT(27) +#define NPCM7XX_SWR3RST BIT(26) +#define NPCM7XX_SWR4RST BIT(25) + +/* WD register */ #define NPCM_WTCR 0x1C#define NPCM_WTCLK (BIT(10) | BIT(11))/* Clock divider */
@@ -43,6 +60,10 @@struct npcm_wdt {struct watchdog_device wdd;void __iomem *reg; +u32 card_reset; +u32 ext1_reset; +u32 ext2_reset; + };static inline struct npcm_wdt *to_npcm_wdt (struct watchdog_device *wdd)
@@ -176,14 +197,70 @@ static const struct watchdog_ops npcm_wdt_ops = { .restart = npcm_wdt_restart, }; +static void npcm_get_reset_status (struct npcm_wdt *wdt,struct device *dev) +{ +struct regmap *gcr_regmap; +u32 rstval; + +if (of_device_is_compatible (dev->of_node,"nuvoton,npcm750-wdt" )) { + gcr_regmap =syscon_regmap_lookup_by_compatible ("nuvoton,npcm750-gcr" ); +if (IS_ERR (gcr_regmap)) { +dev_warn (dev,"Failed to find nuvoton,npcm750-gcr WD reset status not supported\n" ); + } + +regmap_read (gcr_regmap,NPCM7XX_RESSR_OFFSET , &rstval); +if (!rstval) { +regmap_read (gcr_regmap,NPCM7XX_INTCR2_OFFSET , &rstval); + rstval = ~rstval; + } + +if (rstval & wdt->card_reset) + wdt->wdd.bootstatus |=WDIOF_CARDRESET ; +if (rstval & wdt->ext1_reset) + wdt->wdd.bootstatus |=WDIOF_EXTERN1 ; +if (rstval & wdt->ext2_reset) + wdt->wdd.bootstatus |=WDIOF_EXTERN2 ; + } + +} + +static u32 npcm_wdt_reset_type (const char *reset_type) +{ +if (!strcmp (reset_type,"porst" )) +return NPCM7XX_PORST ; +else if (!strcmp (reset_type,"corst" )) +return NPCM7XX_CORST ; +else if (!strcmp (reset_type,"wd0" )) +return NPCM7XX_WD0RST ; +else if (!strcmp (reset_type,"wd1" )) +return NPCM7XX_WD1RST ; +else if (!strcmp (reset_type,"wd2" )) +return NPCM7XX_WD2RST ; +else if (!strcmp (reset_type,"sw1" )) +return NPCM7XX_SWR1RST ; +else if (!strcmp (reset_type,"sw2" )) +return NPCM7XX_SWR2RST ; +else if (!strcmp (reset_type,"sw3" )) +return NPCM7XX_SWR3RST ; +else if (!strcmp (reset_type,"sw4" )) +return NPCM7XX_SWR4RST ; + +return 0 ; +} +static int npcm_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +const char *card_reset_type; +const char *ext1_reset_type; +const char *ext2_reset_type;struct npcm_wdt *wdt; +struct resource *res; +u32 priority;int irq;int ret; - wdt =devm_kzalloc (dev,sizeof (*wdt),GFP_KERNEL ); + wdt =devm_kzalloc (&pdev->dev,sizeof (*wdt),GFP_KERNEL );if (!wdt)return -ENOMEM ;
@@ -195,6 +272,45 @@ static int npcm_wdt_probe(struct platform_device *pdev)if (irq <0 )return irq; +if (of_property_read_u32 (pdev->dev.of_node,"nuvoton,restart-priority" , + &priority)) +watchdog_set_restart_priority (&wdt->wdd,128 ); +else +watchdog_set_restart_priority (&wdt->wdd, priority); + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,card-reset-type" , + &card_reset_type); +if (ret) + wdt->card_reset =NPCM7XX_PORST ; +else { + wdt->card_reset =npcm_wdt_reset_type (card_reset_type); +if (!wdt->card_reset) + wdt->card_reset =NPCM7XX_PORST ; + } + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,ext1-reset-type" , + &ext1_reset_type); +if (ret) + wdt->ext1_reset =NPCM7XX_WD0RST ; +else { + wdt->ext1_reset =npcm_wdt_reset_type (ext1_reset_type); +if (!wdt->ext1_reset) + wdt->ext1_reset =NPCM7XX_WD0RST ; + } + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,ext2-reset-type" , + &ext2_reset_type); +if (ret) + wdt->ext2_reset =NPCM7XX_SWR1RST ; +else { + wdt->ext2_reset =npcm_wdt_reset_type (ext2_reset_type); +if (!wdt->ext2_reset) + wdt->ext2_reset =NPCM7XX_SWR1RST ; + } + wdt->wdd.info = &npcm_wdt_info; wdt->wdd.ops = &npcm_wdt_ops; wdt->wdd.min_timeout =1 ;
@@ -213,6 +329,7 @@ static int npcm_wdt_probe(struct platform_device *pdev)set_bit (WDOG_HW_RUNNING , &wdt->wdd.status); } +npcm_get_reset_status (wdt, dev); ret =devm_request_irq (dev, irq, npcm_wdt_interrupt,0 ,"watchdog" , wdt);if (ret)
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 6/11 pinctrl: npcm7xx: Add HGPIO pin support to NPCM7xx pinctrl driver
In reply to Tomer Maimon--- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 65 +++++++++++++++++------ 1 file changed, 49 insertions(+), 16 deletions(-)
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +49 -16
@@ -504,6 +504,15 @@ static const int lkgpo2_pins[] = { 9 };static const int nprd_smi_pins[] = {190 }; +static const int hgpio0_pins[] = {20 }; +static const int hgpio1_pins[] = {21 }; +static const int hgpio2_pins[] = {22 }; +static const int hgpio3_pins[] = {23 }; +static const int hgpio4_pins[] = {24 }; +static const int hgpio5_pins[] = {25 }; +static const int hgpio6_pins[] = {59 }; +static const int hgpio7_pins[] = {60 }; +/* * pin: name, number * group: name, npins, pins
@@ -631,6 +640,14 @@ struct npcm7xx_group {NPCM7XX_GRP (lkgpo1), \NPCM7XX_GRP (lkgpo2), \NPCM7XX_GRP (nprd_smi), \ +NPCM7XX_GRP (hgpio0), \ +NPCM7XX_GRP (hgpio1), \ +NPCM7XX_GRP (hgpio2), \ +NPCM7XX_GRP (hgpio3), \ +NPCM7XX_GRP (hgpio4), \ +NPCM7XX_GRP (hgpio5), \ +NPCM7XX_GRP (hgpio6), \ +NPCM7XX_GRP (hgpio7), \ \ enum {
@@ -774,6 +791,14 @@ NPCM7XX_SFUNC(lkgpo0);NPCM7XX_SFUNC (lkgpo1);NPCM7XX_SFUNC (lkgpo2);NPCM7XX_SFUNC (nprd_smi); +NPCM7XX_SFUNC (hgpio0); +NPCM7XX_SFUNC (hgpio1); +NPCM7XX_SFUNC (hgpio2); +NPCM7XX_SFUNC (hgpio3); +NPCM7XX_SFUNC (hgpio4); +NPCM7XX_SFUNC (hgpio5); +NPCM7XX_SFUNC (hgpio6); +NPCM7XX_SFUNC (hgpio7);/* Function names */ static struct npcm7xx_func npcm7xx_funcs[] = {
@@ -892,6 +917,14 @@ static struct npcm7xx_func npcm7xx_funcs[] = {NPCM7XX_MKFUNC (lkgpo1),NPCM7XX_MKFUNC (lkgpo2),NPCM7XX_MKFUNC (nprd_smi), +NPCM7XX_MKFUNC (hgpio0), +NPCM7XX_MKFUNC (hgpio1), +NPCM7XX_MKFUNC (hgpio2), +NPCM7XX_MKFUNC (hgpio3), +NPCM7XX_MKFUNC (hgpio4), +NPCM7XX_MKFUNC (hgpio5), +NPCM7XX_MKFUNC (hgpio6), + NPCM7XX_MKFUNC(hgpio7), };#define NPCM7XX_PINCFG (a, b, c, d, e, f, g, h, i, j, k) \
@@ -944,12 +977,12 @@ static const struct npcm7xx_pincfg pincfg[] = {NPCM7XX_PINCFG (17 , pspi2,MFSEL3 ,13 , smb4den,I2CSEGSEL ,23 , none,NONE ,0 ,DS (8 ,12 )),NPCM7XX_PINCFG (18 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )),NPCM7XX_PINCFG (19 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (20 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (21 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (22 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (23 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (24 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (25 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (20 , hgpio0,MFSEL2 ,24 , smb15,MFSEL3 ,8 , smb4c,I2CSEGSEL ,15 ,0 ), +NPCM7XX_PINCFG (21 , hgpio1,MFSEL2 ,25 , smb15,MFSEL3 ,8 , smb4c,I2CSEGSEL ,15 ,0 ), +NPCM7XX_PINCFG (22 , hgpio2,MFSEL2 ,26 , smb14,MFSEL3 ,7 , smb4d,I2CSEGSEL ,16 ,0 ), +NPCM7XX_PINCFG (23 , hgpio3,MFSEL2 ,27 , smb14,MFSEL3 ,7 , smb4d,I2CSEGSEL ,16 ,0 ), +NPCM7XX_PINCFG (24 , hgpio4,MFSEL2 ,28 , ioxh,MFSEL3 ,18 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (25 , hgpio5,MFSEL2 ,29 , ioxh,MFSEL3 ,18 , none,NONE ,0 ,DS (8 ,12 )),NPCM7XX_PINCFG (26 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (27 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(28, smb4, MFSEL1, 1, none, NONE, 0, none, NONE, 0, 0),
@@ -982,8 +1015,8 @@ static const struct npcm7xx_pincfg pincfg[] = {NPCM7XX_PINCFG (56 , r1err,MFSEL1 ,12 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (57 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )),NPCM7XX_PINCFG (58 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (59 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (60 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ), +NPCM7XX_PINCFG (59 , hgpio6,MFSEL2 ,30 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 ,0 ), +NPCM7XX_PINCFG (60 , hgpio7,MFSEL2 ,31 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (61 , uart1,MFSEL1 ,10 , none,NONE ,0 , none,NONE ,0 ,GPO ),NPCM7XX_PINCFG (62 , uart1,MFSEL1 ,10 , bmcuart1,MFSEL3 ,24 , none,NONE ,0 ,GPO ), NPCM7XX_PINCFG(63, uart1, MFSEL1, 10, bmcuart1, MFSEL3, 24, none, NONE, 0, GPO),
@@ -1188,12 +1221,12 @@ static const struct pinctrl_pin_desc npcm7xx_pins[] = {PINCTRL_PIN (17 ,"GPIO17/PSPI2DI/SMB4DEN" ),PINCTRL_PIN (18 ,"GPIO18/PSPI2D0/SMB4BSDA" ),PINCTRL_PIN (19 ,"GPIO19/PSPI2CK/SMB4BSCL" ), -PINCTRL_PIN (20 ,"GPIO20/SMB4CSDA/SMB15SDA" ), -PINCTRL_PIN (21 ,"GPIO21/SMB4CSCL/SMB15SCL" ), -PINCTRL_PIN (22 ,"GPIO22/SMB4DSDA/SMB14SDA" ), -PINCTRL_PIN (23 ,"GPIO23/SMB4DSCL/SMB14SCL" ), -PINCTRL_PIN (24 ,"GPIO24/IOXHDO" ), -PINCTRL_PIN (25 ,"GPIO25/IOXHDI" ), +PINCTRL_PIN (20 ,"GPIO20/HGPIO0/SMB4CSDA/SMB15SDA" ), +PINCTRL_PIN (21 ,"GPIO21/HGPIO1/SMB4CSCL/SMB15SCL" ), +PINCTRL_PIN (22 ,"GPIO22/HGPIO2/SMB4DSDA/SMB14SDA" ), +PINCTRL_PIN (23 ,"GPIO23/HGPIO3/SMB4DSCL/SMB14SCL" ), +PINCTRL_PIN (24 ,"GPIO24/HGPIO4/IOXHDO" ), +PINCTRL_PIN (25 ,"GPIO25/HGPIO5/IOXHDI" ),PINCTRL_PIN (26 ,"GPIO26/SMB5SDA" ),PINCTRL_PIN (27 ,"GPIO27/SMB5SCL" ), PINCTRL_PIN(28, "GPIO28/SMB4SDA"),
@@ -1226,8 +1259,8 @@ static const struct pinctrl_pin_desc npcm7xx_pins[] = {PINCTRL_PIN (56 ,"GPIO56/R1RXERR" ),PINCTRL_PIN (57 ,"GPIO57/R1MDC" ),PINCTRL_PIN (58 ,"GPIO58/R1MDIO" ), -PINCTRL_PIN (59 ,"GPIO59/SMB3DSDA" ), -PINCTRL_PIN (60 ,"GPIO60/SMB3DSCL" ), +PINCTRL_PIN (59 ,"GPIO59/HGPIO6/SMB3DSDA" ), +PINCTRL_PIN (60 ,"GPIO60/HGPIO7/SMB3DSCL" ),PINCTRL_PIN (61 ,"GPO61/nDTR1_BOUT1/STRAP6" ),PINCTRL_PIN (62 ,"GPO62/nRTST1/STRAP5" ), PINCTRL_PIN(63, "GPO63/TXD1/STRAP4"),
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 9/11 spi: npcm-pspi: Add full duplex support
In reply to Tomer MaimonModify the IRQ handler in the NPCM PSPI
driver to support SPI full duplex communication.
--- drivers/spi/spi-npcm-pspi.c | 75 +++++++++++++++---------------------- 1 file changed, 30 insertions(+), 45 deletions(-)
drivers/spi/spi-npcm-pspi.c +30 -45
@@ -197,22 +197,22 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi,static void npcm_pspi_send (struct npcm_pspi *priv) {int wsize; -u16 val; +u16 val =0 ; wsize =min (bytes_per_word (priv->bits_per_word), priv->tx_bytes); priv->tx_bytes -= wsize; -if (!priv->tx_buf) -return ; -switch (wsize) {case 1 : - val = *priv->tx_buf++; +if (priv->tx_buf) + val = *priv->tx_buf++;iowrite8 (val,NPCM_PSPI_DATA + priv->base);break ;case 2 : - val = *priv->tx_buf++; - val = *priv->tx_buf++ | (val <<8 ); +if (priv->tx_buf) { + val = *priv->tx_buf++; + val = *priv->tx_buf++ | (val <<8 ); + }iowrite16 (val,NPCM_PSPI_DATA + priv->base);break ;default :
@@ -224,22 +224,24 @@ static void npcm_pspi_send(struct npcm_pspi *priv)static void npcm_pspi_recv (struct npcm_pspi *priv) {int rsize; -u16 val; +u16 val_16; +u8 val_8; rsize =min (bytes_per_word (priv->bits_per_word), priv->rx_bytes); priv->rx_bytes -= rsize; -if (!priv->rx_buf) -return ; -switch (rsize) {case 1 : - *priv->rx_buf++ =ioread8 (priv->base +NPCM_PSPI_DATA ); + val_8 =ioread8 (priv->base +NPCM_PSPI_DATA ); +if (priv->rx_buf) + *priv->rx_buf++ = val_8;break ;case 2 : - val =ioread16 (priv->base +NPCM_PSPI_DATA ); - *priv->rx_buf++ = (val >>8 ); - *priv->rx_buf++ = val &0xff ; + val_16 =ioread16 (priv->base +NPCM_PSPI_DATA ); +if (priv->rx_buf) { + *priv->rx_buf++ = (val_16 >>8 ); + *priv->rx_buf++ = val_16 &0xff ; + }break ;default :WARN_ON_ONCE (1 );
@@ -298,43 +300,26 @@ static irqreturn_t npcm_pspi_handler(int irq, void *dev_id)struct npcm_pspi *priv = dev_id;u8 stat; - stat =ioread8 (priv->base +NPCM_PSPI_STAT ); -if (!priv->tx_buf && !priv->rx_buf)return IRQ_NONE ; -if (priv->tx_buf) { -if (stat &NPCM_PSPI_STAT_RBF ) { -ioread8 (NPCM_PSPI_DATA + priv->base); -if (priv->tx_bytes ==0 ) { -npcm_pspi_disable (priv); -complete (&priv->xfer_done); -return IRQ_HANDLED ; - } - } - -if ((stat &NPCM_PSPI_STAT_BSY ) ==0 ) -if (priv->tx_bytes) -npcm_pspi_send (priv); +if (priv->tx_bytes ==0 && priv->rx_bytes ==0 ) { +npcm_pspi_disable (priv); +complete (&priv->xfer_done); +return IRQ_HANDLED ; } -if (priv->rx_buf) { -if (stat &NPCM_PSPI_STAT_RBF ) { -if (!priv->rx_bytes) -return IRQ_NONE ; - -npcm_pspi_recv (priv); + stat =ioread8 (priv->base +NPCM_PSPI_STAT ); -if (!priv->rx_bytes) { -npcm_pspi_disable (priv); -complete (&priv->xfer_done); -return IRQ_HANDLED ; - } - } +/* +* first we do the read since if we do the write we previous read might +* be lost (indeed low chances) +*/ +if ((stat &NPCM_PSPI_STAT_RBF ) && priv->rx_bytes) +npcm_pspi_recv (priv); -if (((stat &NPCM_PSPI_STAT_BSY ) ==0 ) && !priv->tx_buf) -iowrite8 (0x0 ,NPCM_PSPI_DATA + priv->base); - } +if (((stat &NPCM_PSPI_STAT_BSY ) ==0 ) && priv->tx_bytes) +npcm_pspi_send (priv);return IRQ_HANDLED ; }
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 1/11 clk: npcm7xx: add read only flag to divider clocks
In reply to Tomer MaimonAdd read only flag to all divider clocks except
SPI3 clock.
--- drivers/clk/clk-npcm7xx.c | 70 +++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 32 deletions(-)
drivers/clk/clk-npcm7xx.c +38 -32
@@ -370,67 +370,73 @@ static const struct npcm7xx_clk_div_fixed_data npcm7xx_divs_fx[] __initconst = {/* configurable dividers: */ static const struct npcm7xx_clk_div_data npcm7xx_divs[]__initconst = { - {NPCM7XX_CLKDIV1 ,28 ,3 ,NPCM7XX_CLK_S_ADC , -NPCM7XX_CLK_S_TIMER ,CLK_DIVIDER_POWER_OF_TWO ,0 ,NPCM7XX_CLK_ADC }, + {NPCM7XX_CLKDIV1 ,28 ,3 ,NPCM7XX_CLK_S_ADC ,NPCM7XX_CLK_S_TIMER , +CLK_DIVIDER_READ_ONLY |CLK_DIVIDER_POWER_OF_TWO ,0 , +NPCM7XX_CLK_ADC },/*30-28 ADCCKDIV*/ - {NPCM7XX_CLKDIV1 ,26 ,2 ,NPCM7XX_CLK_S_AHB , -NPCM7XX_CLK_S_AXI ,0 ,CLK_IS_CRITICAL ,NPCM7XX_CLK_AHB }, + {NPCM7XX_CLKDIV1 ,26 ,2 ,NPCM7XX_CLK_S_AHB ,NPCM7XX_CLK_S_AXI , +CLK_DIVIDER_READ_ONLY ,CLK_IS_CRITICAL ,NPCM7XX_CLK_AHB },/*27-26 CLK4DIV*/ {NPCM7XX_CLKDIV1 ,21 ,5 ,NPCM7XX_CLK_S_TIMER , -NPCM7XX_CLK_S_TIM_MUX ,0 ,0 ,NPCM7XX_CLK_TIMER }, +NPCM7XX_CLK_S_TIM_MUX ,CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_TIMER },/*25-21 TIMCKDIV*/ {NPCM7XX_CLKDIV1 ,16 ,5 ,NPCM7XX_CLK_S_UART , -NPCM7XX_CLK_S_UART_MUX ,0 ,0 ,NPCM7XX_CLK_UART }, +NPCM7XX_CLK_S_UART_MUX ,CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_UART },/*20-16 UARTDIV*/ {NPCM7XX_CLKDIV1 ,11 ,5 ,NPCM7XX_CLK_S_MMC , -NPCM7XX_CLK_S_SD_MUX ,0 ,0 ,NPCM7XX_CLK_MMC }, +NPCM7XX_CLK_S_SD_MUX ,CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_MMC },/*15-11 MMCCKDIV*/ {NPCM7XX_CLKDIV1 ,6 ,5 ,NPCM7XX_CLK_S_SPI3 ,NPCM7XX_CLK_S_AHB ,0 ,0 ,NPCM7XX_CLK_SPI3 },/*10-6 AHB3CKDIV*/ {NPCM7XX_CLKDIV1 ,2 ,4 ,NPCM7XX_CLK_S_PCI , -NPCM7XX_CLK_S_GFX_MUX ,0 ,0 ,NPCM7XX_CLK_PCI }, +NPCM7XX_CLK_S_GFX_MUX ,CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_PCI },/*5-2 PCICKDIV*/ - {NPCM7XX_CLKDIV1 ,0 ,1 ,NPCM7XX_CLK_S_AXI , -NPCM7XX_CLK_S_CPU_MUX ,CLK_DIVIDER_POWER_OF_TWO ,CLK_IS_CRITICAL , -NPCM7XX_CLK_AXI },/*0 CLK2DIV*/ + {NPCM7XX_CLKDIV1 ,0 ,1 ,NPCM7XX_CLK_S_AXI ,NPCM7XX_CLK_S_CPU_MUX , +CLK_DIVIDER_READ_ONLY |CLK_DIVIDER_POWER_OF_TWO , +CLK_IS_CRITICAL ,NPCM7XX_CLK_AXI },/*0 CLK2DIV*/ - {NPCM7XX_CLKDIV2 ,30 ,2 ,NPCM7XX_CLK_S_APB4 , -NPCM7XX_CLK_S_AHB ,CLK_DIVIDER_POWER_OF_TWO ,0 ,NPCM7XX_CLK_APB4 }, + {NPCM7XX_CLKDIV2 ,30 ,2 ,NPCM7XX_CLK_S_APB4 ,NPCM7XX_CLK_S_AHB , +CLK_DIVIDER_READ_ONLY |CLK_DIVIDER_POWER_OF_TWO ,0 , +NPCM7XX_CLK_APB4 },/*31-30 APB4CKDIV*/ - {NPCM7XX_CLKDIV2 ,28 ,2 ,NPCM7XX_CLK_S_APB3 , -NPCM7XX_CLK_S_AHB ,CLK_DIVIDER_POWER_OF_TWO ,0 ,NPCM7XX_CLK_APB3 }, + {NPCM7XX_CLKDIV2 ,28 ,2 ,NPCM7XX_CLK_S_APB3 ,NPCM7XX_CLK_S_AHB , +CLK_DIVIDER_READ_ONLY |CLK_DIVIDER_POWER_OF_TWO ,0 , +NPCM7XX_CLK_APB3 },/*29-28 APB3CKDIV*/ - {NPCM7XX_CLKDIV2 ,26 ,2 ,NPCM7XX_CLK_S_APB2 , -NPCM7XX_CLK_S_AHB ,CLK_DIVIDER_POWER_OF_TWO ,0 ,NPCM7XX_CLK_APB2 }, + {NPCM7XX_CLKDIV2 ,26 ,2 ,NPCM7XX_CLK_S_APB2 ,NPCM7XX_CLK_S_AHB , +CLK_DIVIDER_READ_ONLY |CLK_DIVIDER_POWER_OF_TWO ,0 , +NPCM7XX_CLK_APB2 },/*27-26 APB2CKDIV*/ - {NPCM7XX_CLKDIV2 ,24 ,2 ,NPCM7XX_CLK_S_APB1 , -NPCM7XX_CLK_S_AHB ,CLK_DIVIDER_POWER_OF_TWO ,0 ,NPCM7XX_CLK_APB1 }, + {NPCM7XX_CLKDIV2 ,24 ,2 ,NPCM7XX_CLK_S_APB1 ,NPCM7XX_CLK_S_AHB , +CLK_DIVIDER_READ_ONLY |CLK_DIVIDER_POWER_OF_TWO ,0 , +NPCM7XX_CLK_APB1 },/*25-24 APB1CKDIV*/ - {NPCM7XX_CLKDIV2 ,22 ,2 ,NPCM7XX_CLK_S_APB5 , -NPCM7XX_CLK_S_AHB ,CLK_DIVIDER_POWER_OF_TWO ,0 ,NPCM7XX_CLK_APB5 }, + {NPCM7XX_CLKDIV2 ,22 ,2 ,NPCM7XX_CLK_S_APB5 ,NPCM7XX_CLK_S_AHB , +CLK_DIVIDER_READ_ONLY |CLK_DIVIDER_POWER_OF_TWO ,0 , +NPCM7XX_CLK_APB5 },/*23-22 APB5CKDIV*/ - {NPCM7XX_CLKDIV2 ,16 ,5 ,NPCM7XX_CLK_S_CLKOUT , -NPCM7XX_CLK_S_CLKOUT_MUX ,0 ,0 ,NPCM7XX_CLK_CLKOUT }, + {NPCM7XX_CLKDIV2 ,16 ,5 ,NPCM7XX_CLK_S_CLKOUT ,NPCM7XX_CLK_S_CLKOUT_MUX , +CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_CLKOUT },/*20-16 CLKOUTDIV*/ - {NPCM7XX_CLKDIV2 ,13 ,3 ,NPCM7XX_CLK_S_GFX , -NPCM7XX_CLK_S_GFX_MUX ,0 ,0 ,NPCM7XX_CLK_GFX }, + {NPCM7XX_CLKDIV2 ,13 ,3 ,NPCM7XX_CLK_S_GFX ,NPCM7XX_CLK_S_GFX_MUX , +CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_GFX },/*15-13 GFXCKDIV*/ - {NPCM7XX_CLKDIV2 ,8 ,5 ,NPCM7XX_CLK_S_USB_BRIDGE , -NPCM7XX_CLK_S_SU_MUX ,0 ,0 ,NPCM7XX_CLK_SU }, + {NPCM7XX_CLKDIV2 ,8 ,5 ,NPCM7XX_CLK_S_USB_BRIDGE ,NPCM7XX_CLK_S_SU_MUX , +CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_SU },/*12-8 SUCKDIV*/ - {NPCM7XX_CLKDIV2 ,4 ,4 ,NPCM7XX_CLK_S_USB_HOST , -NPCM7XX_CLK_S_SU_MUX ,0 ,0 ,NPCM7XX_CLK_SU48 }, + {NPCM7XX_CLKDIV2 ,4 ,4 ,NPCM7XX_CLK_S_USB_HOST ,NPCM7XX_CLK_S_SU_MUX , +CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_SU48 },/*7-4 SU48CKDIV*/ {NPCM7XX_CLKDIV2 ,0 ,4 ,NPCM7XX_CLK_S_SDHC , -NPCM7XX_CLK_S_SD_MUX ,0 ,0 ,NPCM7XX_CLK_SDHC } +NPCM7XX_CLK_S_SD_MUX ,CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_SDHC } ,/*3-0 SD1CKDIV*/ {NPCM7XX_CLKDIV3 ,6 ,5 ,NPCM7XX_CLK_S_SPI0 , -NPCM7XX_CLK_S_AHB ,0 ,0 ,NPCM7XX_CLK_SPI0 }, +NPCM7XX_CLK_S_AHB ,CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_SPI0 },/*10-6 SPI0CKDV*/ {NPCM7XX_CLKDIV3 ,1 ,5 ,NPCM7XX_CLK_S_SPIX , -NPCM7XX_CLK_S_AHB ,0 ,0 ,NPCM7XX_CLK_SPIX }, +NPCM7XX_CLK_S_AHB ,CLK_DIVIDER_READ_ONLY ,0 ,NPCM7XX_CLK_SPIX },/*5-1 SPIXCKDV*/ };
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 10/11 dt-binding: bmc: add NPCM7XX JTAG master documentation
In reply to Tomer MaimonAdded device tree binding documentation for
Nuvoton NPCM7XX JTAG master.
--- .../bindings/bmc/npcm7xx-jtag-master.txt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/bmc/npcm7xx-jtag-master.txt
Documentation/devicetree/bindings/bmc/npcm7xx-jtag-master.txt new file +38 -0
@@ -0,0 +1,38 @@ +Nuvoton NPCM7xx JTAG MASTER interface + +Nuvoton BMC NPCM7xx JTAG Master is used for debugging host CPU or programming +CPLD device. The driver is implemented as an SPI device driver that enabling +the option to transfer JTAG data with the assistance of SPI HW. + +Required properties for jtag_master node +- compatible : "nuvoton,npcm750-jtag-master" for Poleg NPCM7XX. +- spi-max-frequency : specify the max spi bus frequency. +- reg : always 0 +- pinctrl-names : contain 2 pinctrl states "pspi" and "gpio", which indicates + the TCK/TDI/TDO pin state in HW mode(using PSPI hw) and + SW mode (using GPIO bitbang) respectively. +- tck-gpios : specify the GPIO number of TCK pin +- tdi-gpios : specify the GPIO number of TDI pin +- tdo-gpios : specify the GPIO number of TDO pin +- tms-gpios : specify the GPIO number of TMS pin + +Example: +spi1: spi@201000 { + ... + jtag_master { + compatible = "nuvoton,npcm750-jtag-master"; + spi-max-frequency = <25000000>; + reg = <0>; + + pinctrl-names = "pspi", "gpio"; + pinctrl-0 = <&pspi2_pins>; + pinctrl-1 = <&gpio17_pins &gpio18o_pins + &gpio19ol_pins>; + + tck-gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>; + tdi-gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; + tdo-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; + tms-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + status = "okay"; + }; +};
Signature · 1 line
2.22.0
Tomer Maimon
maintainerPATCH v2 11/11 misc: npcm7xx-jtag-master: add NPCM7xx JTAG master driver
In reply to Tomer MaimonAdd NPCM7xx JTAG master driver,
The NPCM7xx JTAG master usign GPIO lines
and NPCM PSPI bus.
--- drivers/misc/Kconfig | 6 + drivers/misc/Makefile | 1 + drivers/misc/npcm7xx-jtag-master.c | 840 +++++++++++++++++++++++++++++ 3 files changed, 847 insertions(+) create mode 100644 drivers/misc/npcm7xx-jtag-master.c
drivers/misc/Kconfig +6 -0
@@ -478,6 +478,12 @@ config NPCM7XX_PCI_MBOX Expose the NPCM750/730/715/705 PCI MBOX registers found on Nuvoton SOCs to userspace. +config NPCM7XX_JTAG_MASTER + tristate "NPCM7xx JTAG Master driver" + depends on (ARCH_NPCM7XX || COMPILE_TEST) + help + Control PSPI/GPIO to transmit jtag signals to support jtag master function. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -59,4 +59,5 @@ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_NPCM7XX_LPC_BPC) += npcm7xx-lpc-bpc.o obj-$(CONFIG_NPCM7XX_PCI_MBOX) += npcm7xx-pci-mbox.o +obj-$(CONFIG_NPCM7XX_JTAG_MASTER) += npcm7xx-jtag-master.o obj-$(CONFIG_MCTP_LPC) += mctp-lpc.o
drivers/misc/npcm7xx-jtag-master.c new file +840 -0
840 lines not on this page · raw message
Signature · 1 line
2.22.0
Hi Tomer,
Quoted 3 lines · Tomer Maimon
In this patch set we will like to align with relevant modifications in Nuvoton OpenBMC Linux kernel 5.4.
Thanks for sending the patches. I can merge them into 5.8, however I have a v5.10 branch that I plan on moving to imminently.
Quoted 10 lines
Linux upstream current status:
1. npcm7xx clock driver - adding read only
flag to divider clocks, Will be sent to Linux community.
2. Adding NPCM ADC calibration - Will be sent to Linux vanilla, but I am not sure it will be approved.
3. Add DT restart priority and reset type support - sent to Linux community la but havent approved yet.
4. persist configuration to the pin control driver - asked by a costumer, didnt sent to Linux community.
Do you plan on sending it?
Quoted 4 lines
5. Add HGPIO pin support to NPCM7xx pinctrl driver - will be sent to Linux community
6. JTAG master driver - will be sent to Linux community once we will have BMC folder.
As you've noted, I recommend you submit them to mainline ASAP to avoid extra handling of patches in the openbmc tree.
Cheers,
Joel
Quoted 38 lines
Changes since version 1:
- Address comments from Jonathan Neuschäfer: removing trailing whitespace in NPCM watchdog documentation.
- Adding Stanley Chu to NPCM JTAG master driverTomer Maimon (11):
clk: npcm7xx: add read only flag to divider clocks
iio: adc: add calibration support to npcm ADC
dts: npcm750: add fuse regmap support node
watchdog: npcm: Add DT restart priority and reset type support
dt-binding: watchdog: Add DT restart priority and reset type
pinctrl: npcm7xx: Add HGPIO pin support to NPCM7xx pinctrl driver
pinctrl: pinconf: add pin persist configuration
pinctrl: npcm7xx: Add pin persist configuration support
spi: npcm-pspi: Add full duplex support
dt-binding: bmc: add NPCM7XX JTAG master documentation
misc: npcm7xx-jtag-master: add NPCM7xx JTAG master driver.../bindings/bmc/npcm7xx-jtag-master.txt | 38 + .../bindings/watchdog/nuvoton,npcm-wdt.txt | 32 + arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi | 6 + drivers/clk/clk-npcm7xx.c | 70 +- drivers/iio/adc/npcm_adc.c | 191 ++++ drivers/misc/Kconfig | 6 + drivers/misc/Makefile | 1 + drivers/misc/npcm7xx-jtag-master.c | 840 ++++++++++++++++++ drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 130 ++- drivers/pinctrl/pinconf-generic.c | 3 + drivers/spi/spi-npcm-pspi.c | 75 +- drivers/watchdog/npcm_wdt.c | 121 ++- 12 files changed, 1418 insertions(+), 95 deletions(-) create mode 100644 Documentation/devicetree/bindings/bmc/npcm7xx-jtag-master.txt create mode 100644 drivers/misc/npcm7xx-jtag-master.c--
2.22.0
Re: [PATCH linux dev-5.8 v2 02/11] iio: adc: add calibration support to npcm ADC
In reply to Tomer MaimonQuoted 3 lines · Tomer Maimon
Add calibration to improve accuracy measurement when using internal referance voltage.
reference
Quoted 4 lines
the calibration values taken from the FUSE module.
Signed-off-by Tomer Maimon <[email protected]>
I recommend taking a look at the proposed device tree changes before we merge this one, so we don't have an incompatibility between future code and device tree.
Quoted 59 lines
--- drivers/iio/adc/npcm_adc.c | 191 +++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+)drivers/iio/adc/npcm_adc.c +36
-0@@ -17,6 +17,8 @@#include <linux/reset.h> struct npcm_adc { +u32 R05; +u32 R15;bool int_status;u32 adc_sample_hz;struct device *dev;@@ -51,6 +53,40 @@ struct npcm_adc {#define NPCM_RESOLUTION_BITS 10#define NPCM_INT_VREF_MV 2000 +/* FUSE registers */ +#define NPCM7XX_FST 0x00 +#define NPCM7XX_FADDR 0x04 +#define NPCM7XX_FDATA 0x08 +#define NPCM7XX_FCFG 0x0C +#define NPCM7XX_FCTL 0x14 + +/* FST Register Bits */ +#define NPCM7XX_FST_RDY BIT(0) +#define NPCM7XX_FST_RDST BIT(1) + +/* FADDR Register Bits */ +#define NPCM7XX_FADDR_BYTEADDR BIT(0) +#define NPCM7XX_FADDR_BYTEADDR_MASK GENMASK(9, 0) + +/* FADDR Register Bits */ +#define NPCM7XX_FDATA_DATA BIT(0) +#define NPCM7XX_FDATA_CLEAN_VALUE BIT(1) +#define NPCM7XX_FDATA_DATA_MASK GENMASK(7, 0) + +/* FCTL Register Bits */ +#define NPCM7XX_FCTL_RDST BIT(1) + +/* ADC Calibration Definition */ +#define NPCM_INT_1500MV 768 +#define NPCM_INT_1000MV 512 +#define NPCM_ADC_MIN_VAL 0 +#define NPCM_ADC_MAX_VAL 1023 + +#define FUSE_CALIB_ADDR 24 +#define FUSE_CALIB_SIZE 8 +#define DATA_CALIB_SIZE 4 +#define FUSE_READ_TIMEOUT 0xDEADBEEF +#define NPCM_ADC_CHAN (ch) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \
drivers/iio/adc/npcm_adc.c static const struct iio_chan_spec npcm_adc_iio_channels[] = { · line 116
Quoted 10 lines
drivers/iio/adc/npcm_adc.c +7
-0@@ -71,6 +107,133 @@ static const struct iio_chan_spec npcm_adc_iio_channels[] = { NPCM_ADC_CHAN(7), }; +static int npcm750_fuse_wait_for_ready (struct regmap *fuse_regmap,u32 timeout) +{ +u32 time = timeout; +u32 fstreg; + +while (--time >1 ) { +regmap_read (fuse_regmap,NPCM7XX_FST , &fstreg);
regmap_read_poll_timeout
Quoted 9 lines
drivers/iio/adc/npcm_adc.c +9
-0+if (fstreg &NPCM7XX_FST_RDY ) { +regmap_write_bits (fuse_regmap,NPCM7XX_FST , +NPCM7XX_FST_RDST ,NPCM7XX_FST_RDST ); +return 0 ; + } + } + +/* try to clear the status in case it was set */ + regmap_write_bits(fuse_regmap, NPCM7XX_FST, NPCM7XX_FST_RDST,
drivers/iio/adc/npcm_adc.c static const struct iio_chan_spec npcm_adc_iio_channels[] = { · line 135
Quoted 10 lines
drivers/iio/adc/npcm_adc.c +10
-0+ NPCM7XX_FST_RDST); + +return -EINVAL ; +} + +static void npcm750_fuse_read (struct regmap *fuse_regmap,u32 addr,u8 *data) +{ +u32 val; + +npcm750_fuse_wait_for_ready (fuse_regmap,FUSE_READ_TIMEOUT );
This ignores the time out.
drivers/iio/adc/npcm_adc.c static const struct iio_chan_spec npcm_adc_iio_channels[] = { · line 142
Quoted 7 lines
drivers/iio/adc/npcm_adc.c +7
-0+ +regmap_write_bits (fuse_regmap,NPCM7XX_FADDR , +NPCM7XX_FADDR_BYTEADDR_MASK , addr); +regmap_read (fuse_regmap,NPCM7XX_FADDR , &val); +regmap_write (fuse_regmap,NPCM7XX_FCTL ,NPCM7XX_FCTL_RDST ); + +npcm750_fuse_wait_for_ready (fuse_regmap,FUSE_READ_TIMEOUT );
...as does this.
Quoted 58 lines
drivers/iio/adc/npcm_adc.c +58
-0+regmap_read (fuse_regmap,NPCM7XX_FDATA , &val); + *data = (u8 )val; + +regmap_write_bits (fuse_regmap,NPCM7XX_FDATA ,NPCM7XX_FDATA_DATA_MASK , +NPCM7XX_FDATA_CLEAN_VALUE ); +} + +static int npcm750_ECC_to_nibble (u8 ECC ,u8 nibble) +{ +u8 nibble_b0 = (nibble >>0 ) &BIT (0 ); +u8 nibble_b1 = (nibble >>1 ) &BIT (0 ); +u8 nibble_b2 = (nibble >>2 ) &BIT (0 ); +u8 nibble_b3 = (nibble >>3 ) &BIT (0 ); +u8 tmp_ECC = nibble; + + tmp_ECC |= (nibble_b0 ^ nibble_b1) <<4 | (nibble_b2 ^ nibble_b3) <<5 | + (nibble_b0 ^ nibble_b2) <<6 | (nibble_b1 ^ nibble_b3) <<7 ; + +if (tmp_ECC !=ECC ) +return -EINVAL ; + +return 0 ; +} + +static int npcm750_ECC_to_byte (u16 ECC ,u8 *Byte) +{ +u8 nibble_L, nibble_H; +u8 ECC_L ,ECC_H ; + +ECC_H =ECC >>8 ; + nibble_H =ECC_H &0x0F ; +ECC_L =ECC >>0 ; + nibble_L =ECC_L &0x0F ; + +if (npcm750_ECC_to_nibble (ECC_H , nibble_H) !=0 || +npcm750_ECC_to_nibble (ECC_L , nibble_L) !=0 ) +return -EINVAL ; + + *Byte = nibble_H <<4 | nibble_L <<0 ; + +return 0 ; +} + +static int npcm750_read_nibble_parity (u8 *block_ECC,u8 *ADC_calib) +{ +int i; +u16 ECC ; + +for (i =0 ; i <DATA_CALIB_SIZE ; i++) { +memcpy (&ECC , block_ECC + (i *2 ),2 ); +if (npcm750_ECC_to_byte (ECC , &ADC_calib[i]) !=0 ) +return -EINVAL ; + } + +return 0 ; +} + +static int npcm750_fuse_calibration_read(struct platform_device *pdev,
drivers/iio/adc/npcm_adc.c static const struct iio_chan_spec npcm_adc_iio_channels[] = { · line 210
Quoted 10 lines
drivers/iio/adc/npcm_adc.c +10
-0+ struct npcm_adc *info) +{ +struct device_node *np = pdev->dev.of_node; +struct regmap *fuse_regmap; +ssize_t bytes_read =0 ; +u8 read_buf[8 ]; +u32 ADC_calib; +u32 addr =FUSE_CALIB_ADDR ; + +if (of_device_is_compatible (np,"nuvoton,npcm750-adc" )) {
This will always be true.
drivers/iio/adc/npcm_adc.c static const struct iio_chan_spec npcm_adc_iio_channels[] = { · line 212
Quoted 2 lines
drivers/iio/adc/npcm_adc.c +2
-0+ fuse_regmap =syscon_regmap_lookup_by_compatible + ("nuvoton,npcm750-fuse" );
If you use a phandle to the fuse node, you can have the one code base support multiple families of chips. Use syscon_regmap_lookup_by_phandle(np, "syscon")
and in your device tree:
adc: adc@c000 {
compatible = "nuvoton,npcm750-adc";
reg = <0xc000 0x8>;
interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk NPCM7XX_CLK_ADC>;
resets = <&rstc NPCM7XX_RESET_IPSRST1
NPCM7XX_RESET_ADC>;
syscon = <&fuse_syscon>;
};Quoted 4 lines
drivers/iio/adc/npcm_adc.c +4
-0+if (IS_ERR (fuse_regmap)) { +dev_warn (&pdev->dev,"Failed to find nuvoton,npcm750-fuse\n" ); +return PTR_ERR (fuse_regmap); + }
drivers/iio/adc/npcm_adc.c static const struct iio_chan_spec npcm_adc_iio_channels[] = { · line 226
Quoted 10 lines
drivers/iio/adc/npcm_adc.c +10
-0+ +while (bytes_read <FUSE_CALIB_SIZE ) { +npcm750_fuse_read (fuse_regmap, addr, + &read_buf[bytes_read]); + bytes_read++; + addr++; + } + +if (npcm750_read_nibble_parity (read_buf, (u8 *)&ADC_calib)) { +dev_warn (info->dev,"FUSE Clibration read failed\n" );
calibration
Quoted 65 lines
drivers/iio/adc/npcm_adc.c +38
-1+return -EINVAL ; + } + + info->R05 = ADC_calib &0xFFFF ; + info->R15 = ADC_calib >>16 ; + } + +return 0 ; +} +static irqreturn_t npcm_adc_isr (int irq,void *data) {u32 regtemp;@@ -125,6 +288,29 @@ static int npcm_adc_read(struct npcm_adc *info, int *val, u8 channel)return 0 ; } +static void npcm_adc_calibration (int *val,struct npcm_adc *info) +{ +int mul_val; +int offset_val; + + mul_val =NPCM_INT_1000MV * (*val - info->R15); +if (mul_val <0 ) { + mul_val = mul_val *-1 ; + offset_val =DIV_ROUND_CLOSEST (mul_val, + (info->R15 - info->R05)); + *val =NPCM_INT_1500MV - offset_val; + }else { + offset_val =DIV_ROUND_CLOSEST (mul_val, + (info->R15 - info->R05)); + *val =NPCM_INT_1500MV + offset_val; + } + +if (*val <NPCM_ADC_MIN_VAL ) + *val =NPCM_ADC_MIN_VAL ; +if (*val >NPCM_ADC_MAX_VAL ) + *val =NPCM_ADC_MAX_VAL ; +} +static int npcm_adc_read_raw (struct iio_dev *indio_dev,struct iio_chan_spec const *chan,int *val,int *val2,long mask)@@ -142,6 +328,10 @@ static int npcm_adc_read_raw(struct iio_dev *indio_dev,dev_err (info->dev,"NPCM ADC read failed\n" );return ret; } + +if ((info->R05 || info->R15) &&IS_ERR (info->vref)) +npcm_adc_calibration (val, info); +return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE :if (!IS_ERR (info->vref)) {@@ -248,6 +438,7 @@ static int npcm_adc_probe(struct platform_device *pdev) info->regs + NPCM_ADCCON); } +npcm750_fuse_calibration_read (pdev, info);init_waitqueue_head (&info->wq); reg_con =ioread32 (info->regs +NPCM_ADCCON ); --2.22.0
Re: [PATCH linux dev-5.8 v2 04/11] watchdog: npcm: Add DT restart priority and reset type support
In reply to Tomer MaimonQuoted 5 lines · Tomer Maimon
Add Device tree restart priority and
three reset types support.Signed-off-by Tomer Maimon <[email protected]>
Can you remind me the history of this change. Was a similar patch rejected by mainline?
Quoted 46 lines
--- drivers/watchdog/npcm_wdt.c | 121 +++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-)drivers/watchdog/npcm_wdt.c +22
-1@@ -11,7 +11,24 @@#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/watchdog.h> - +#include <linux/regmap.h> +#include <linux/mfd/syscon.h> + +/* NPCM7xx GCR module */ +#define NPCM7XX_RESSR_OFFSET 0x6C +#define NPCM7XX_INTCR2_OFFSET 0x60 + +#define NPCM7XX_PORST BIT(31) +#define NPCM7XX_CORST BIT(30) +#define NPCM7XX_WD0RST BIT(29) +#define NPCM7XX_WD1RST BIT(24) +#define NPCM7XX_WD2RST BIT(23) +#define NPCM7XX_SWR1RST BIT(28) +#define NPCM7XX_SWR2RST BIT(27) +#define NPCM7XX_SWR3RST BIT(26) +#define NPCM7XX_SWR4RST BIT(25) + +/* WD register */ #define NPCM_WTCR 0x1C#define NPCM_WTCLK (BIT(10) | BIT(11))/* Clock divider */ @@ -43,6 +60,10 @@struct npcm_wdt {struct watchdog_device wdd;void __iomem *reg; +u32 card_reset; +u32 ext1_reset; +u32 ext2_reset; + };static inline struct npcm_wdt *to_npcm_wdt (struct watchdog_device *wdd)
drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 206
Quoted 10 lines
drivers/watchdog/npcm_wdt.c +7
-0@@ -176,14 +197,70 @@ static const struct watchdog_ops npcm_wdt_ops = { .restart = npcm_wdt_restart, }; +static void npcm_get_reset_status (struct npcm_wdt *wdt,struct device *dev) +{ +struct regmap *gcr_regmap; +u32 rstval; + +if (of_device_is_compatible (dev->of_node,"nuvoton,npcm750-wdt" )) { + gcr_regmap =syscon_regmap_lookup_by_compatible ("nuvoton,npcm750-gcr" );
This will have the same issues as the ADC with supporting multiple families of chip with the same code. I suggest you adjust it to use the phandle approach.
Quoted 118 lines
drivers/watchdog/npcm_wdt.c +90
-2+if (IS_ERR (gcr_regmap)) { +dev_warn (dev,"Failed to find nuvoton,npcm750-gcr WD reset status not supported\n" ); + } + +regmap_read (gcr_regmap,NPCM7XX_RESSR_OFFSET , &rstval); +if (!rstval) { +regmap_read (gcr_regmap,NPCM7XX_INTCR2_OFFSET , &rstval); + rstval = ~rstval; + } + +if (rstval & wdt->card_reset) + wdt->wdd.bootstatus |=WDIOF_CARDRESET ; +if (rstval & wdt->ext1_reset) + wdt->wdd.bootstatus |=WDIOF_EXTERN1 ; +if (rstval & wdt->ext2_reset) + wdt->wdd.bootstatus |=WDIOF_EXTERN2 ; + } + +} + +static u32 npcm_wdt_reset_type (const char *reset_type) +{ +if (!strcmp (reset_type,"porst" )) +return NPCM7XX_PORST ; +else if (!strcmp (reset_type,"corst" )) +return NPCM7XX_CORST ; +else if (!strcmp (reset_type,"wd0" )) +return NPCM7XX_WD0RST ; +else if (!strcmp (reset_type,"wd1" )) +return NPCM7XX_WD1RST ; +else if (!strcmp (reset_type,"wd2" )) +return NPCM7XX_WD2RST ; +else if (!strcmp (reset_type,"sw1" )) +return NPCM7XX_SWR1RST ; +else if (!strcmp (reset_type,"sw2" )) +return NPCM7XX_SWR2RST ; +else if (!strcmp (reset_type,"sw3" )) +return NPCM7XX_SWR3RST ; +else if (!strcmp (reset_type,"sw4" )) +return NPCM7XX_SWR4RST ; + +return 0 ; +} +static int npcm_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +const char *card_reset_type; +const char *ext1_reset_type; +const char *ext2_reset_type;struct npcm_wdt *wdt; +struct resource *res; +u32 priority;int irq;int ret; - wdt =devm_kzalloc (dev,sizeof (*wdt),GFP_KERNEL ); + wdt =devm_kzalloc (&pdev->dev,sizeof (*wdt),GFP_KERNEL );if (!wdt)return -ENOMEM ;@@ -195,6 +272,45 @@ static int npcm_wdt_probe(struct platform_device *pdev)if (irq <0 )return irq; +if (of_property_read_u32 (pdev->dev.of_node,"nuvoton,restart-priority" , + &priority)) +watchdog_set_restart_priority (&wdt->wdd,128 ); +else +watchdog_set_restart_priority (&wdt->wdd, priority); + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,card-reset-type" , + &card_reset_type); +if (ret) + wdt->card_reset =NPCM7XX_PORST ; +else { + wdt->card_reset =npcm_wdt_reset_type (card_reset_type); +if (!wdt->card_reset) + wdt->card_reset =NPCM7XX_PORST ; + } + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,ext1-reset-type" , + &ext1_reset_type); +if (ret) + wdt->ext1_reset =NPCM7XX_WD0RST ; +else { + wdt->ext1_reset =npcm_wdt_reset_type (ext1_reset_type); +if (!wdt->ext1_reset) + wdt->ext1_reset =NPCM7XX_WD0RST ; + } + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,ext2-reset-type" , + &ext2_reset_type); +if (ret) + wdt->ext2_reset =NPCM7XX_SWR1RST ; +else { + wdt->ext2_reset =npcm_wdt_reset_type (ext2_reset_type); +if (!wdt->ext2_reset) + wdt->ext2_reset =NPCM7XX_SWR1RST ; + } + wdt->wdd.info = &npcm_wdt_info; wdt->wdd.ops = &npcm_wdt_ops; wdt->wdd.min_timeout =1 ;@@ -213,6 +329,7 @@ static int npcm_wdt_probe(struct platform_device *pdev)set_bit (WDOG_HW_RUNNING , &wdt->wdd.status); } +npcm_get_reset_status (wdt, dev); ret =devm_request_irq (dev, irq, npcm_wdt_interrupt,0 ,"watchdog" , wdt);if (ret) --2.22.0
Re: [PATCH linux dev-5.8 v2 06/11] pinctrl: npcm7xx: Add HGPIO pin support to NPCM7xx pinctrl driver
In reply to Tomer MaimonQuoted 2 lines · Tomer Maimon
Signed-off-by Tomer Maimon <[email protected]>
This one should go upstream asap.
Quoted 132 lines
--- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 65 +++++++++++++++++------ 1 file changed, 49 insertions(+), 16 deletions(-)drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +49
-17@@ -504,6 +504,15 @@ static const int lkgpo2_pins[] = { 9 };static const int nprd_smi_pins[] = {190 }; +static const int hgpio0_pins[] = {20 }; +static const int hgpio1_pins[] = {21 }; +static const int hgpio2_pins[] = {22 }; +static const int hgpio3_pins[] = {23 }; +static const int hgpio4_pins[] = {24 }; +static const int hgpio5_pins[] = {25 }; +static const int hgpio6_pins[] = {59 }; +static const int hgpio7_pins[] = {60 }; +/* * pin: name, number * group: name, npins, pins @@ -631,6 +640,14 @@ struct npcm7xx_group {NPCM7XX_GRP (lkgpo1), \NPCM7XX_GRP (lkgpo2), \NPCM7XX_GRP (nprd_smi), \ +NPCM7XX_GRP (hgpio0), \ +NPCM7XX_GRP (hgpio1), \ +NPCM7XX_GRP (hgpio2), \ +NPCM7XX_GRP (hgpio3), \ +NPCM7XX_GRP (hgpio4), \ +NPCM7XX_GRP (hgpio5), \ +NPCM7XX_GRP (hgpio6), \ +NPCM7XX_GRP (hgpio7), \ \ enum {@@ -774,6 +791,14 @@ NPCM7XX_SFUNC(lkgpo0);NPCM7XX_SFUNC (lkgpo1);NPCM7XX_SFUNC (lkgpo2);NPCM7XX_SFUNC (nprd_smi); +NPCM7XX_SFUNC (hgpio0); +NPCM7XX_SFUNC (hgpio1); +NPCM7XX_SFUNC (hgpio2); +NPCM7XX_SFUNC (hgpio3); +NPCM7XX_SFUNC (hgpio4); +NPCM7XX_SFUNC (hgpio5); +NPCM7XX_SFUNC (hgpio6); +NPCM7XX_SFUNC (hgpio7);/* Function names */ static struct npcm7xx_func npcm7xx_funcs[] = {@@ -892,6 +917,14 @@ static struct npcm7xx_func npcm7xx_funcs[] = {NPCM7XX_MKFUNC (lkgpo1),NPCM7XX_MKFUNC (lkgpo2),NPCM7XX_MKFUNC (nprd_smi), +NPCM7XX_MKFUNC (hgpio0), +NPCM7XX_MKFUNC (hgpio1), +NPCM7XX_MKFUNC (hgpio2), +NPCM7XX_MKFUNC (hgpio3), +NPCM7XX_MKFUNC (hgpio4), +NPCM7XX_MKFUNC (hgpio5), +NPCM7XX_MKFUNC (hgpio6), + NPCM7XX_MKFUNC(hgpio7), };#define NPCM7XX_PINCFG (a, b, c, d, e, f, g, h, i, j, k) \@@ -944,12 +977,12 @@ static const struct npcm7xx_pincfg pincfg[] = {NPCM7XX_PINCFG (17 , pspi2,MFSEL3 ,13 , smb4den,I2CSEGSEL ,23 , none,NONE ,0 ,DS (8 ,12 )),NPCM7XX_PINCFG (18 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )),NPCM7XX_PINCFG (19 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (20 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (21 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (22 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (23 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (24 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (25 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (20 , hgpio0,MFSEL2 ,24 , smb15,MFSEL3 ,8 , smb4c,I2CSEGSEL ,15 ,0 ), +NPCM7XX_PINCFG (21 , hgpio1,MFSEL2 ,25 , smb15,MFSEL3 ,8 , smb4c,I2CSEGSEL ,15 ,0 ), +NPCM7XX_PINCFG (22 , hgpio2,MFSEL2 ,26 , smb14,MFSEL3 ,7 , smb4d,I2CSEGSEL ,16 ,0 ), +NPCM7XX_PINCFG (23 , hgpio3,MFSEL2 ,27 , smb14,MFSEL3 ,7 , smb4d,I2CSEGSEL ,16 ,0 ), +NPCM7XX_PINCFG (24 , hgpio4,MFSEL2 ,28 , ioxh,MFSEL3 ,18 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (25 , hgpio5,MFSEL2 ,29 , ioxh,MFSEL3 ,18 , none,NONE ,0 ,DS (8 ,12 )),NPCM7XX_PINCFG (26 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (27 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(28, smb4, MFSEL1, 1, none, NONE, 0, none, NONE, 0, 0),@@ -982,8 +1015,8 @@ static const struct npcm7xx_pincfg pincfg[] = {NPCM7XX_PINCFG (56 , r1err,MFSEL1 ,12 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (57 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )),NPCM7XX_PINCFG (58 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (59 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (60 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ), +NPCM7XX_PINCFG (59 , hgpio6,MFSEL2 ,30 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 ,0 ), +NPCM7XX_PINCFG (60 , hgpio7,MFSEL2 ,31 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (61 , uart1,MFSEL1 ,10 , none,NONE ,0 , none,NONE ,0 ,GPO ),NPCM7XX_PINCFG (62 , uart1,MFSEL1 ,10 , bmcuart1,MFSEL3 ,24 , none,NONE ,0 ,GPO ), NPCM7XX_PINCFG(63, uart1, MFSEL1, 10, bmcuart1, MFSEL3, 24, none, NONE, 0, GPO),@@ -1188,12 +1221,12 @@ static const struct pinctrl_pin_desc npcm7xx_pins[] = {PINCTRL_PIN (17 ,"GPIO17/PSPI2DI/SMB4DEN" ),PINCTRL_PIN (18 ,"GPIO18/PSPI2D0/SMB4BSDA" ),PINCTRL_PIN (19 ,"GPIO19/PSPI2CK/SMB4BSCL" ), -PINCTRL_PIN (20 ,"GPIO20/SMB4CSDA/SMB15SDA" ), -PINCTRL_PIN (21 ,"GPIO21/SMB4CSCL/SMB15SCL" ), -PINCTRL_PIN (22 ,"GPIO22/SMB4DSDA/SMB14SDA" ), -PINCTRL_PIN (23 ,"GPIO23/SMB4DSCL/SMB14SCL" ), -PINCTRL_PIN (24 ,"GPIO24/IOXHDO" ), -PINCTRL_PIN (25 ,"GPIO25/IOXHDI" ), +PINCTRL_PIN (20 ,"GPIO20/HGPIO0/SMB4CSDA/SMB15SDA" ), +PINCTRL_PIN (21 ,"GPIO21/HGPIO1/SMB4CSCL/SMB15SCL" ), +PINCTRL_PIN (22 ,"GPIO22/HGPIO2/SMB4DSDA/SMB14SDA" ), +PINCTRL_PIN (23 ,"GPIO23/HGPIO3/SMB4DSCL/SMB14SCL" ), +PINCTRL_PIN (24 ,"GPIO24/HGPIO4/IOXHDO" ), +PINCTRL_PIN (25 ,"GPIO25/HGPIO5/IOXHDI" ),PINCTRL_PIN (26 ,"GPIO26/SMB5SDA" ),PINCTRL_PIN (27 ,"GPIO27/SMB5SCL" ), PINCTRL_PIN(28, "GPIO28/SMB4SDA"),@@ -1226,8 +1259,8 @@ static const struct pinctrl_pin_desc npcm7xx_pins[] = {PINCTRL_PIN (56 ,"GPIO56/R1RXERR" ),PINCTRL_PIN (57 ,"GPIO57/R1MDC" ),PINCTRL_PIN (58 ,"GPIO58/R1MDIO" ), -PINCTRL_PIN (59 ,"GPIO59/SMB3DSDA" ), -PINCTRL_PIN (60 ,"GPIO60/SMB3DSCL" ), +PINCTRL_PIN (59 ,"GPIO59/HGPIO6/SMB3DSDA" ), +PINCTRL_PIN (60 ,"GPIO60/HGPIO7/SMB3DSCL" ),PINCTRL_PIN (61 ,"GPO61/nDTR1_BOUT1/STRAP6" ),PINCTRL_PIN (62 ,"GPO62/nRTST1/STRAP5" ), PINCTRL_PIN(63, "GPO63/TXD1/STRAP4"), --2.22.0
Re: [PATCH linux dev-5.8 v2 09/11] spi: npcm-pspi: Add full duplex support
In reply to Tomer MaimonQuoted 15 lines · Tomer Maimon
Modify the IRQ handler in the NPCM PSPI
driver to support SPI full duplex communication.Signed-off-by Tomer Maimon <[email protected]>--- drivers/spi/spi-npcm-pspi.c | 75 +++++++++++++++---------------------- 1 file changed, 30 insertions(+), 45 deletions(-)drivers/spi/spi-npcm-pspi.c +0
-0@@ -197,22 +197,22 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi,static void npcm_pspi_send (struct npcm_pspi *priv)
drivers/spi/spi-npcm-pspi.c static void npcm_pspi_setup_transfer(struct spi_device *spi, · line 206
Quoted 10 lines
drivers/spi/spi-npcm-pspi.c +1
-3{int wsize; -u16 val; +u16 val =0 ; wsize =min (bytes_per_word (priv->bits_per_word), priv->tx_bytes); priv->tx_bytes -= wsize; -if (!priv->tx_buf) -return ;
It looks like you're removing this check and instead doing it inside each case. That seems like a waste, why not leave the single check in?
Quoted 111 lines
drivers/spi/spi-npcm-pspi.c +29
-43-switch (wsize) {case 1 : - val = *priv->tx_buf++; +if (priv->tx_buf) + val = *priv->tx_buf++;iowrite8 (val,NPCM_PSPI_DATA + priv->base);break ;case 2 : - val = *priv->tx_buf++; - val = *priv->tx_buf++ | (val <<8 ); +if (priv->tx_buf) { + val = *priv->tx_buf++; + val = *priv->tx_buf++ | (val <<8 ); + }iowrite16 (val,NPCM_PSPI_DATA + priv->base);break ;default :@@ -224,22 +224,24 @@ static void npcm_pspi_send(struct npcm_pspi *priv)static void npcm_pspi_recv (struct npcm_pspi *priv) {int rsize; -u16 val; +u16 val_16; +u8 val_8; rsize =min (bytes_per_word (priv->bits_per_word), priv->rx_bytes); priv->rx_bytes -= rsize; -if (!priv->rx_buf) -return ; -switch (rsize) {case 1 : - *priv->rx_buf++ =ioread8 (priv->base +NPCM_PSPI_DATA ); + val_8 =ioread8 (priv->base +NPCM_PSPI_DATA ); +if (priv->rx_buf) + *priv->rx_buf++ = val_8;break ;case 2 : - val =ioread16 (priv->base +NPCM_PSPI_DATA ); - *priv->rx_buf++ = (val >>8 ); - *priv->rx_buf++ = val &0xff ; + val_16 =ioread16 (priv->base +NPCM_PSPI_DATA ); +if (priv->rx_buf) { + *priv->rx_buf++ = (val_16 >>8 ); + *priv->rx_buf++ = val_16 &0xff ; + }break ;default :WARN_ON_ONCE (1 );@@ -298,43 +300,26 @@ static irqreturn_t npcm_pspi_handler(int irq, void *dev_id)struct npcm_pspi *priv = dev_id;u8 stat; - stat =ioread8 (priv->base +NPCM_PSPI_STAT ); -if (!priv->tx_buf && !priv->rx_buf)return IRQ_NONE ; -if (priv->tx_buf) { -if (stat &NPCM_PSPI_STAT_RBF ) { -ioread8 (NPCM_PSPI_DATA + priv->base); -if (priv->tx_bytes ==0 ) { -npcm_pspi_disable (priv); -complete (&priv->xfer_done); -return IRQ_HANDLED ; - } - } - -if ((stat &NPCM_PSPI_STAT_BSY ) ==0 ) -if (priv->tx_bytes) -npcm_pspi_send (priv); +if (priv->tx_bytes ==0 && priv->rx_bytes ==0 ) { +npcm_pspi_disable (priv); +complete (&priv->xfer_done); +return IRQ_HANDLED ; } -if (priv->rx_buf) { -if (stat &NPCM_PSPI_STAT_RBF ) { -if (!priv->rx_bytes) -return IRQ_NONE ; - -npcm_pspi_recv (priv); + stat =ioread8 (priv->base +NPCM_PSPI_STAT ); -if (!priv->rx_bytes) { -npcm_pspi_disable (priv); -complete (&priv->xfer_done); -return IRQ_HANDLED ; - } - } +/* +* first we do the read since if we do the write we previous read might +* be lost (indeed low chances) +*/ +if ((stat &NPCM_PSPI_STAT_RBF ) && priv->rx_bytes) +npcm_pspi_recv (priv); -if (((stat &NPCM_PSPI_STAT_BSY ) ==0 ) && !priv->tx_buf) -iowrite8 (0x0 ,NPCM_PSPI_DATA + priv->base); - } +if (((stat &NPCM_PSPI_STAT_BSY ) ==0 ) && priv->tx_bytes) +npcm_pspi_send (priv);return IRQ_HANDLED ; } --2.22.0
Avi Fishman
maintainerRe: [PATCH linux dev-5.8 v2 09/11] spi: npcm-pspi: Add full duplex support
Quoted 22 lines · Joel Stanley
Quoted 20 lines · Tomer Maimon
Modify the IRQ handler in the NPCM PSPI
driver to support SPI full duplex communication.Signed-off-by Tomer Maimon <[email protected]>--- drivers/spi/spi-npcm-pspi.c | 75 +++++++++++++++---------------------- 1 file changed, 30 insertions(+), 45 deletions(-)drivers/spi/spi-npcm-pspi.c +1
-1@@ -197,22 +197,22 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi,static void npcm_pspi_send (struct npcm_pspi *priv) {int wsize; -u16 val; +u16 val =0 ;
Quoted 8 lines
drivers/spi/spi-npcm-pspi.c static void npcm_pspi_setup_transfer(struct spi_device *spi, · line 206
Quoted 5 lines
drivers/spi/spi-npcm-pspi.c +0
-2wsize =min (bytes_per_word (priv->bits_per_word), priv->tx_bytes); priv->tx_bytes -= wsize; -if (!priv->tx_buf) -return ;It looks like you're removing this check and instead doing it inside each case. That seems like a waste, why not leave the single check in?
Even if the tx_buf is NULL, I still need to do the write to NPCM_PSPI_DATA, since only this write triggers the clock and I need the clocks for the rx_buf.
and this is why I initialized 'val = 0'
Quoted 112 lines
Quoted 112 lines
drivers/spi/spi-npcm-pspi.c +29
-43-switch (wsize) {case 1 : - val = *priv->tx_buf++; +if (priv->tx_buf) + val = *priv->tx_buf++;iowrite8 (val,NPCM_PSPI_DATA + priv->base);break ;case 2 : - val = *priv->tx_buf++; - val = *priv->tx_buf++ | (val <<8 ); +if (priv->tx_buf) { + val = *priv->tx_buf++; + val = *priv->tx_buf++ | (val <<8 ); + }iowrite16 (val,NPCM_PSPI_DATA + priv->base);break ;default :@@ -224,22 +224,24 @@ static void npcm_pspi_send(struct npcm_pspi *priv)static void npcm_pspi_recv (struct npcm_pspi *priv) {int rsize; -u16 val; +u16 val_16; +u8 val_8; rsize =min (bytes_per_word (priv->bits_per_word), priv->rx_bytes); priv->rx_bytes -= rsize; -if (!priv->rx_buf) -return ; -switch (rsize) {case 1 : - *priv->rx_buf++ =ioread8 (priv->base +NPCM_PSPI_DATA ); + val_8 =ioread8 (priv->base +NPCM_PSPI_DATA ); +if (priv->rx_buf) + *priv->rx_buf++ = val_8;break ;case 2 : - val =ioread16 (priv->base +NPCM_PSPI_DATA ); - *priv->rx_buf++ = (val >>8 ); - *priv->rx_buf++ = val &0xff ; + val_16 =ioread16 (priv->base +NPCM_PSPI_DATA ); +if (priv->rx_buf) { + *priv->rx_buf++ = (val_16 >>8 ); + *priv->rx_buf++ = val_16 &0xff ; + }break ;default :WARN_ON_ONCE (1 );@@ -298,43 +300,26 @@ static irqreturn_t npcm_pspi_handler(int irq, void *dev_id)struct npcm_pspi *priv = dev_id;u8 stat; - stat =ioread8 (priv->base +NPCM_PSPI_STAT ); -if (!priv->tx_buf && !priv->rx_buf)return IRQ_NONE ; -if (priv->tx_buf) { -if (stat &NPCM_PSPI_STAT_RBF ) { -ioread8 (NPCM_PSPI_DATA + priv->base); -if (priv->tx_bytes ==0 ) { -npcm_pspi_disable (priv); -complete (&priv->xfer_done); -return IRQ_HANDLED ; - } - } - -if ((stat &NPCM_PSPI_STAT_BSY ) ==0 ) -if (priv->tx_bytes) -npcm_pspi_send (priv); +if (priv->tx_bytes ==0 && priv->rx_bytes ==0 ) { +npcm_pspi_disable (priv); +complete (&priv->xfer_done); +return IRQ_HANDLED ; } -if (priv->rx_buf) { -if (stat &NPCM_PSPI_STAT_RBF ) { -if (!priv->rx_bytes) -return IRQ_NONE ; - -npcm_pspi_recv (priv); + stat =ioread8 (priv->base +NPCM_PSPI_STAT ); -if (!priv->rx_bytes) { -npcm_pspi_disable (priv); -complete (&priv->xfer_done); -return IRQ_HANDLED ; - } - } +/* +* first we do the read since if we do the write we previous read might +* be lost (indeed low chances) +*/ +if ((stat &NPCM_PSPI_STAT_RBF ) && priv->rx_bytes) +npcm_pspi_recv (priv); -if (((stat &NPCM_PSPI_STAT_BSY ) ==0 ) && !priv->tx_buf) -iowrite8 (0x0 ,NPCM_PSPI_DATA + priv->base); - } +if (((stat &NPCM_PSPI_STAT_BSY ) ==0 ) && priv->tx_bytes) +npcm_pspi_send (priv);return IRQ_HANDLED ; } --2.22.0
Signature · 2 lines
Regards, Avi
Tomer Maimon
maintainerRe: [PATCH linux dev-5.8 v2 04/11] watchdog: npcm: Add DT restart priority and reset type support
In reply to Joel StanleyQuoted 10 lines · Joel Stanley
Quoted 5 lines · Tomer Maimon
Add Device tree restart priority and
three reset types support.Signed-off-by Tomer Maimon <[email protected]>Can you remind me the history of this change. Was a similar patch rejected by mainline?
https://www.spinics.net/lists/kernel/msg3425926.html
Quoted 58 lines
Quoted 47 lines
--- drivers/watchdog/npcm_wdt.c | 121 +++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-)drivers/watchdog/npcm_wdt.c +22
-1@@ -11,7 +11,24 @@#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/watchdog.h> - +#include <linux/regmap.h> +#include <linux/mfd/syscon.h> + +/* NPCM7xx GCR module */ +#define NPCM7XX_RESSR_OFFSET 0x6C +#define NPCM7XX_INTCR2_OFFSET 0x60 + +#define NPCM7XX_PORST BIT(31) +#define NPCM7XX_CORST BIT(30) +#define NPCM7XX_WD0RST BIT(29) +#define NPCM7XX_WD1RST BIT(24) +#define NPCM7XX_WD2RST BIT(23) +#define NPCM7XX_SWR1RST BIT(28) +#define NPCM7XX_SWR2RST BIT(27) +#define NPCM7XX_SWR3RST BIT(26) +#define NPCM7XX_SWR4RST BIT(25) + +/* WD register */ #define NPCM_WTCR 0x1C#define NPCM_WTCLK (BIT(10) | BIT(11))/* Clock divider */ @@ -43,6 +60,10 @@struct npcm_wdt {struct watchdog_device wdd;void __iomem *reg; +u32 card_reset; +u32 ext1_reset; +u32 ext2_reset; + };static inline struct npcm_wdt *to_npcm_wdt (struct watchdog_device *wdd)drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 200
Quoted 4 lines
drivers/watchdog/npcm_wdt.c +1
-0@@ -176,14 +197,70 @@ static const struct watchdog_ops npcm_wdt_ops = { .restart = npcm_wdt_restart, }; +static void npcm_get_reset_status(struct npcm_wdt *wdt, struct device*dev)
drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = {
Quoted 5 lines
drivers/watchdog/npcm_wdt.c +5
-0+{ +struct regmap *gcr_regmap; +u32 rstval; + + if (of_device_is_compatible(dev->of_node,"nuvoton,npcm750-wdt")) {
Quoted 8 lines
drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 206
Quoted 1 line
drivers/watchdog/npcm_wdt.c +1
-0+ gcr_regmap =
syscon_regmap_lookup_by_compatible("nuvoton,npcm750-gcr");This will have the same issues as the ADC with supporting multiple families of chip with the same code. I suggest you adjust it to use the phandle approach.
Do you mean by having a gcr phandle property in the wdt npcm device tree
node?
Quoted 126 lines
drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 208
Quoted 3 lines
drivers/watchdog/npcm_wdt.c +2
-0+if (IS_ERR (gcr_regmap)) { + dev_warn(dev, "Failed to findnuvoton,npcm750-gcr WD reset status not supported\n");
drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = {
Quoted 5 lines
drivers/watchdog/npcm_wdt.c +5
-0+ } + +regmap_read (gcr_regmap,NPCM7XX_RESSR_OFFSET , &rstval); +if (!rstval) { + regmap_read(gcr_regmap, NPCM7XX_INTCR2_OFFSET,&rstval);
drivers/watchdog/npcm_wdt.c static int npcm_wdt_probe(struct platform_device
Quoted 55 lines
drivers/watchdog/npcm_wdt.c +43
-1+ rstval = ~rstval; + } + +if (rstval & wdt->card_reset) + wdt->wdd.bootstatus |=WDIOF_CARDRESET ; +if (rstval & wdt->ext1_reset) + wdt->wdd.bootstatus |=WDIOF_EXTERN1 ; +if (rstval & wdt->ext2_reset) + wdt->wdd.bootstatus |=WDIOF_EXTERN2 ; + } + +} + +static u32 npcm_wdt_reset_type (const char *reset_type) +{ +if (!strcmp (reset_type,"porst" )) +return NPCM7XX_PORST ; +else if (!strcmp (reset_type,"corst" )) +return NPCM7XX_CORST ; +else if (!strcmp (reset_type,"wd0" )) +return NPCM7XX_WD0RST ; +else if (!strcmp (reset_type,"wd1" )) +return NPCM7XX_WD1RST ; +else if (!strcmp (reset_type,"wd2" )) +return NPCM7XX_WD2RST ; +else if (!strcmp (reset_type,"sw1" )) +return NPCM7XX_SWR1RST ; +else if (!strcmp (reset_type,"sw2" )) +return NPCM7XX_SWR2RST ; +else if (!strcmp (reset_type,"sw3" )) +return NPCM7XX_SWR3RST ; +else if (!strcmp (reset_type,"sw4" )) +return NPCM7XX_SWR4RST ; + +return 0 ; +} +static int npcm_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +const char *card_reset_type; +const char *ext1_reset_type; +const char *ext2_reset_type;struct npcm_wdt *wdt; +struct resource *res; +u32 priority;int irq;int ret; - wdt =devm_kzalloc (dev,sizeof (*wdt),GFP_KERNEL ); + wdt =devm_kzalloc (&pdev->dev,sizeof (*wdt),GFP_KERNEL );if (!wdt)return -ENOMEM ;@@ -195,6 +272,45 @@ static int npcm_wdt_probe(struct platform_device*pdev)
drivers/watchdog/npcm_wdt.c static int npcm_wdt_probe(struct platform_device *pdev)
Quoted 4 lines
drivers/watchdog/npcm_wdt.c +1
-0if (irq <0 )return irq; + if (of_property_read_u32(pdev->dev.of_node,"nuvoton,restart-priority",
drivers/watchdog/npcm_wdt.c static int npcm_wdt_probe(struct platform_device
Quoted 42 lines
drivers/watchdog/npcm_wdt.c +38
-0+ &priority)) +watchdog_set_restart_priority (&wdt->wdd,128 ); + else + watchdog_set_restart_priority(&wdt->wdd, priority); + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,card-reset-type" , + &card_reset_type); +if (ret) + wdt->card_reset =NPCM7XX_PORST ; +else { + wdt->card_reset =npcm_wdt_reset_type (card_reset_type); +if (!wdt->card_reset) + wdt->card_reset =NPCM7XX_PORST ; + } + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,ext1-reset-type" , + &ext1_reset_type); +if (ret) + wdt->ext1_reset =NPCM7XX_WD0RST ; +else { + wdt->ext1_reset =npcm_wdt_reset_type (ext1_reset_type); +if (!wdt->ext1_reset) + wdt->ext1_reset =NPCM7XX_WD0RST ; + } + + ret =of_property_read_string (pdev->dev.of_node, +"nuvoton,ext2-reset-type" , + &ext2_reset_type); +if (ret) + wdt->ext2_reset =NPCM7XX_SWR1RST ; +else { + wdt->ext2_reset =npcm_wdt_reset_type (ext2_reset_type); +if (!wdt->ext2_reset) + wdt->ext2_reset =NPCM7XX_SWR1RST ; + } + wdt->wdd.info = &npcm_wdt_info; wdt->wdd.ops = &npcm_wdt_ops; wdt->wdd.min_timeout =1 ;@@ -213,6 +329,7 @@ static int npcm_wdt_probe(struct platform_device*pdev)
drivers/watchdog/npcm_wdt.c static int npcm_wdt_probe(struct platform_device *pdev)
Quoted 5 lines
drivers/watchdog/npcm_wdt.c +1
-0set_bit (WDOG_HW_RUNNING , &wdt->wdd.status); } +npcm_get_reset_status (wdt, dev); ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0,"watchdog",
Quoted 5 lines
drivers/watchdog/npcm_wdt.c +0
-1wdt);if (ret) --2.22.0
Tomer Maimon
maintainerHi Joel,
First tahnks a lot for reviewing the patches.
Quoted 19 lines · Joel Stanley
Hi Tomer,
Quoted 3 lines · Tomer Maimon
In this patch set we will like to align with relevant modifications in Nuvoton OpenBMC Linux kernel 5.4.
Thanks for sending the patches. I can merge them into 5.8, however I have a v5.10 branch that I plan on moving to imminently.
Quoted 9 lines
Linux upstream current status:
1. npcm7xx clock driver - adding read only
flag to divider clocks, Will be sent to Linux community.
2. Adding NPCM ADC calibration - Will be sent to Linux vanilla, but I am not sure it will be approved.
3. Add DT restart priority and reset type support - sent to Linux community la but havent approved yet.
4. persist configuration to the pin control driver - asked by a
Quoted 5 lines
costumer,
Quoted 1 line
didnt sent to Linux community.
Do you plan on sending it?
I need you advise on this one, I pretty sure that the pin cntroller maintainer will refuse to add it
what do you think?
Quoted 7 lines
Quoted 4 lines
5. Add HGPIO pin support to NPCM7xx pinctrl driver - will be sent to Linux community
6. JTAG master driver - will be sent to Linux community once wewill
Quoted 1 line
have BMC folder.
What about the JTAG driver? can you add it please? do I need to move it to soc folder or to leave it in
misc?
Quoted 4 lines
As you've noted, I recommend you submit them to mainline ASAP to avoid extra handling of patches in the openbmc tree.
you right, I will do my best...
Quoted 38 lines
Cheers,
Joel
Quoted 19 lines
Changes since version 1:
- Address comments from Jonathan Neuschäfer: removing trailing whitespace in NPCM watchdog documentation.
- Adding Stanley Chu to NPCM JTAG master driverTomer Maimon (11):
clk: npcm7xx: add read only flag to divider clocks
iio: adc: add calibration support to npcm ADC
dts: npcm750: add fuse regmap support node
watchdog: npcm: Add DT restart priority and reset type support
dt-binding: watchdog: Add DT restart priority and reset type
pinctrl: npcm7xx: Add HGPIO pin support to NPCM7xx pinctrl driver
pinctrl: pinconf: add pin persist configuration
pinctrl: npcm7xx: Add pin persist configuration support
spi: npcm-pspi: Add full duplex support
dt-binding: bmc: add NPCM7XX JTAG master documentation
misc: npcm7xx-jtag-master: add NPCM7xx JTAG master driverQuoted 14 lines
.../bindings/bmc/npcm7xx-jtag-master.txt | 38 + .../bindings/watchdog/nuvoton,npcm-wdt.txt | 32 + arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi | 6 + drivers/clk/clk-npcm7xx.c | 70 +- drivers/iio/adc/npcm_adc.c | 191 ++++ drivers/misc/Kconfig | 6 + drivers/misc/Makefile | 1 + drivers/misc/npcm7xx-jtag-master.c | 840 ++++++++++++++++++ drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 130 ++- drivers/pinctrl/pinconf-generic.c | 3 + drivers/spi/spi-npcm-pspi.c | 75 +- drivers/watchdog/npcm_wdt.c | 121 ++- 12 files changed, 1418 insertions(+), 95 deletions(-) create mode 100644
Quoted 7 lines
Documentation/devicetree/bindings/bmc/npcm7xx-jtag-master.txtQuoted 5 lines
create mode 100644 drivers/misc/npcm7xx-jtag-master.c--
2.22.0
cheers,
Tomer