diff --git a/boards/microchip/sam/sama7g54_ek/sama7g54_ek.dts b/boards/microchip/sam/sama7g54_ek/sama7g54_ek.dts index 0831e19bcc4d1..2b028c3c57753 100644 --- a/boards/microchip/sam/sama7g54_ek/sama7g54_ek.dts +++ b/boards/microchip/sam/sama7g54_ek/sama7g54_ek.dts @@ -121,6 +121,28 @@ }; }; +&flx11 { + mchp,flexcom-mode = ; + status = "okay"; + + spi11: spi@400 { + pinctrl-0 = <&pinctrl_spi11_default>; + pinctrl-names = "default"; + cs-gpios = <&piob 6 GPIO_ACTIVE_LOW>; + status = "okay"; + + nor_flash: sst26vf064@0 { + compatible ="jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <10000000>; + size = ; /* 64 Mbits */ + jedec-id = [bf 26 43]; + requires-ulbpr; + status = "okay"; + }; + }; +}; + &pinctrl { pinctrl_flx3_default: flx3_default { group1 { @@ -179,6 +201,15 @@ }; }; + pinctrl_spi11_default: spi11_default { + group1 { + pinmux = , + , + , + ; /* GPIO CS */ + bias-pull-up; + }; + }; }; &pit64b0 { diff --git a/boards/microchip/sam/sama7g54_ek/sama7g54_ek.yaml b/boards/microchip/sam/sama7g54_ek/sama7g54_ek.yaml index 41122ebe193a2..d560228721297 100644 --- a/boards/microchip/sam/sama7g54_ek/sama7g54_ek.yaml +++ b/boards/microchip/sam/sama7g54_ek/sama7g54_ek.yaml @@ -11,5 +11,6 @@ ram: 128 supported: - sdhc - shell + - spi - uart vendor: microchip diff --git a/drivers/spi/spi_sam.c b/drivers/spi/spi_sam.c index 1ff399503c228..d30a3570c1709 100644 --- a/drivers/spi/spi_sam.c +++ b/drivers/spi/spi_sam.c @@ -101,6 +101,20 @@ static int spi_sam_configure(const struct device *dev, uint16_t spi_csr_idx = spi_cs_is_gpio(config) ? 0 : config->slave; int div; +#ifdef SOC_ATMEL_SAM_MCK_FREQ_HZ + uint32_t rate = SOC_ATMEL_SAM_MCK_FREQ_HZ; +#else + uint32_t rate; + int ret; + + ret = clock_control_get_rate(SAM_DT_PMC_CONTROLLER, + (clock_control_subsys_t)&cfg->clock_cfg, + &rate); + if (ret) { + return ret; + } +#endif + if (spi_context_configured(&data->ctx, config)) { return 0; } @@ -146,7 +160,7 @@ static int spi_sam_configure(const struct device *dev, } /* Use the requested or next highest possible frequency */ - div = SOC_ATMEL_SAM_MCK_FREQ_HZ / config->frequency; + div = rate / config->frequency; div = CLAMP(div, 1, UINT8_MAX); spi_csr |= SPI_CSR_SCBR(div); diff --git a/dts/arm/microchip/sam/sama7g5.dtsi b/dts/arm/microchip/sam/sama7g5.dtsi index c9f290f5dd3e8..b5d1a1c76f747 100644 --- a/dts/arm/microchip/sam/sama7g5.dtsi +++ b/dts/arm/microchip/sam/sama7g5.dtsi @@ -396,6 +396,17 @@ status = "disabled"; }; + spi11: spi@400 { + compatible = "atmel,sam-spi"; + reg = <0x400 0x200>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 49>; + interrupt-parent = <&gic>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + usart11: serial@200 { compatible = "atmel,sam-usart"; reg = <0x200 0x200>; diff --git a/west.yml b/west.yml index 71d88e2997bcc..11a32bbd53836 100644 --- a/west.yml +++ b/west.yml @@ -195,7 +195,7 @@ manifest: groups: - hal - name: hal_microchip - revision: e5fe6469afc53d7aefcc74377dd99ce20428d42b + revision: pull/41/head path: modules/hal/microchip groups: - hal