Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arc: hsdk: bug fixes and new feature supports #19173

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
/drivers/modem/ @mike-scott
/drivers/pcie/ @gnuless
/drivers/pinmux/stm32/ @rsalveti @idlethread
/drivers/pinmux/*hsdk* @iriszzw
/drivers/sensor/ @MaureenHelm
/drivers/sensor/ams_iAQcore/ @alexanderwachter
/drivers/sensor/ens210/ @alexanderwachter
Expand Down
2 changes: 1 addition & 1 deletion arch/arc/core/arc_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ u32_t z_arc_connect_idu_read_mode(u32_t irq_num)
void z_arc_connect_idu_set_dest(u32_t irq_num, u32_t core_mask)
{
LOCKED(&arc_connect_spinlock) {
z_arc_connect_cmd_data(ARC_CONNECT_CMD_IDU_SET_MODE,
z_arc_connect_cmd_data(ARC_CONNECT_CMD_IDU_SET_DEST,
irq_num, core_mask);
}
}
Expand Down
7 changes: 7 additions & 0 deletions boards/arc/hsdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) 2019 Synopsys, Inc. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

zephyr_sources_ifdef(CONFIG_PINMUX_HSDK pinmux.c)
Binary file added boards/arc/hsdk/doc/arduino_shield_interface.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
282 changes: 278 additions & 4 deletions boards/arc/hsdk/doc/index.rst

Large diffs are not rendered by default.

Binary file added boards/arc/hsdk/doc/mikrobus_header.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions boards/arc/hsdk/hsdk_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ CONFIG_ARCV2_TIMER=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_PINMUX=y
CONFIG_PINMUX_HSDK=y
37 changes: 37 additions & 0 deletions boards/arc/hsdk/pinmux.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2019 Synopsys
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <soc.h>
#include <init.h>
#include <drivers/pinmux.h>

static int board_pinmux_init(struct device *device)
{
ARG_UNUSED(device);

struct device *pinmux = device_get_binding(CONFIG_PINMUX_NAME);

if (pinmux == NULL) {
return -ENXIO;
}
/*
* to do configuration for each sel,
* please refer the doc for hsdk board.
*/
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL0, HSDK_PINMUX_FUN0);
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL1, HSDK_PINMUX_FUN0);
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL2, HSDK_PINMUX_FUN0);
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL3, HSDK_PINMUX_FUN2);
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL4, HSDK_PINMUX_FUN0);
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL5, HSDK_PINMUX_FUN0);
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL6, HSDK_PINMUX_FUN0);
pinmux_pin_set(pinmux, HSDK_PINMUX_SEL7, HSDK_PINMUX_FUN0);

return 0;
}


SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
1 change: 1 addition & 0 deletions drivers/pinmux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ zephyr_sources_ifdef(CONFIG_PINMUX_STM32 stm32/pinmux_stm32.c)
zephyr_sources_ifdef(CONFIG_PINMUX_SAM0 pinmux_sam0.c)
zephyr_sources_ifdef(CONFIG_PINMUX_INTEL_S1000 pinmux_intel_s1000.c)
zephyr_sources_ifdef(CONFIG_PINMUX_RV32M1 pinmux_rv32m1.c)
zephyr_sources_ifdef(CONFIG_PINMUX_HSDK pinmux_hsdk.c)
2 changes: 2 additions & 0 deletions drivers/pinmux/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ source "drivers/pinmux/Kconfig.rv32m1"

source "drivers/pinmux/Kconfig.xec"

source "drivers/pinmux/Kconfig.hsdk"

endif # PINMUX
11 changes: 11 additions & 0 deletions drivers/pinmux/Kconfig.hsdk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) 2019 Synopsys, Inc. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

menuconfig PINMUX_HSDK
bool "ARC HSDK I/O pin mux driver"
depends on SOC_ARC_HSDK
help
Enable driver for ARC HSDK I/O pin mux.
70 changes: 70 additions & 0 deletions drivers/pinmux/pinmux_hsdk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2019 Synopsys, Inc. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <errno.h>
#include <device.h>
#include <drivers/pinmux.h>
#include <soc.h>

#define creg_gpio_mux_reg (*(volatile u32_t *)CREG_GPIO_MUX_BASE_ADDR)

void _arc_sync(void)
{
__asm__ volatile("sync");
}

static int pinmux_hsdk_set(struct device *dev, u32_t pin, u32_t func)
{

if (func >= HSDK_PINMUX_FUNS || pin >= HSDK_PINMUX_SELS)
return -EINVAL;

creg_gpio_mux_reg &= ~(0x07U << (pin * 3));
creg_gpio_mux_reg |= (func << (pin * 3));

_arc_sync();

return 0;
}

static int pinmux_hsdk_get(struct device *dev, u32_t pin, u32_t *func)
{

if (pin >= HSDK_PINMUX_SELS || func == NULL)
return -EINVAL;

*func = (creg_gpio_mux_reg >> (pin * 3)) & 0x07U;

return 0;
}

static int pinmux_hsdk_pullup(struct device *dev, u32_t pin, u8_t func)
{
return -ENOTSUP;
}

static int pinmux_hsdk_input(struct device *dev, u32_t pin, u8_t func)
{
return -ENOTSUP;
}

static int pinmux_hsdk_init(struct device *dev)
{
ARG_UNUSED(dev);
return 0;
}

static const struct pinmux_driver_api pinmux_hsdk_driver_api = {
.set = pinmux_hsdk_set,
.get = pinmux_hsdk_get,
.pullup = pinmux_hsdk_pullup,
.input = pinmux_hsdk_input,
};

DEVICE_AND_API_INIT(pinmux_hsdk, CONFIG_PINMUX_NAME,
&pinmux_hsdk_init, NULL, NULL,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_hsdk_driver_api);
9 changes: 9 additions & 0 deletions drivers/spi/Kconfig.dw
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ config SPI_DW_FIFO_DEPTH
SSI_RX_FIFO_DEPTH of the DesignWare Synchronous
Serial Interface. Depth ranges from 2-256.

config SPI_DW_ACCESS_WORD_ONLY
bool "DesignWare SPI only allows word access"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it has nothing to do with either DW SSI controller or with HSDK board per se but instead it depends on APB data bus configuration. So please don't mention HSDK at least here - it's a good justification for commit message but not for Kconfig - other users don't care about HSDK board at all though they might need this feature also.
Moreover in U-Boot we switched to 32-bit only accessed and so far nobody complained, see https://gitlab.denx.de/u-boot/u-boot/commit/4b5f6c52e78d43710a0d062e31de741ec76ceea1 so maybe we do the same thing here?

I.e. don't introduce yet another Kconfig option and just use 32-bit accesses all the time.

Though there seem to be some cases like picoXcell pc3x3 where 16-bit access is really required, see torvalds/linux@c4fe57f

But still if 16-bit access is not needed I'd try to go with 32-bit only for now until somebody starts to complain as this will make code cleaner and simpler for now.

default n
depends on SPI_DW
help
In some case, e.g. ARC HS Development kit, the peripheral space of
DesignWare SPI only allows word access, byte access will raise
exception.

if SPI_0

config SPI_DW_PORT_0_INTERRUPT_SINGLE_LINE
Expand Down
11 changes: 10 additions & 1 deletion drivers/spi/spi_dw.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,21 @@ struct spi_dw_data {
#define z_extra_clock_off(...)

/* Based on those macros above, here are common helpers for some registers */
DEFINE_MM_REG_WRITE(baudr, DW_SPI_REG_BAUDR, 16)

DEFINE_MM_REG_READ(txflr, DW_SPI_REG_TXFLR, 32)
DEFINE_MM_REG_READ(rxflr, DW_SPI_REG_RXFLR, 32)

#ifdef CONFIG_SPI_DW_ACCESS_WORD_ONLY
DEFINE_MM_REG_WRITE(baudr, DW_SPI_REG_BAUDR, 32)
DEFINE_MM_REG_WRITE(imr, DW_SPI_REG_IMR, 32)
DEFINE_MM_REG_READ(imr, DW_SPI_REG_IMR, 32)
DEFINE_MM_REG_READ(isr, DW_SPI_REG_ISR, 32)
#else
DEFINE_MM_REG_WRITE(baudr, DW_SPI_REG_BAUDR, 16)
DEFINE_MM_REG_WRITE(imr, DW_SPI_REG_IMR, 8)
DEFINE_MM_REG_READ(imr, DW_SPI_REG_IMR, 8)
DEFINE_MM_REG_READ(isr, DW_SPI_REG_ISR, 8)
#endif

DEFINE_SET_BIT_OP(ssienr, DW_SPI_REG_SSIENR, DW_SPI_SSIENR_SSIEN_BIT)
DEFINE_CLEAR_BIT_OP(ssienr, DW_SPI_REG_SSIENR, DW_SPI_SSIENR_SSIEN_BIT)
Expand Down
13 changes: 10 additions & 3 deletions drivers/spi/spi_dw_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ extern "C" {
/* Register helpers */
DEFINE_MM_REG_WRITE(ctrlr0, DW_SPI_REG_CTRLR0, 32)
DEFINE_MM_REG_READ(ctrlr0, DW_SPI_REG_CTRLR0, 32)
DEFINE_MM_REG_WRITE(ctrlr1, DW_SPI_REG_CTRLR1, 16)
DEFINE_MM_REG_READ(ctrlr1, DW_SPI_REG_CTRLR1, 16)
DEFINE_MM_REG_WRITE(ser, DW_SPI_REG_SER, 8)
DEFINE_MM_REG_WRITE(txftlr, DW_SPI_REG_TXFTLR, 32)
DEFINE_MM_REG_WRITE(rxftlr, DW_SPI_REG_RXFTLR, 32)
DEFINE_MM_REG_READ(rxftlr, DW_SPI_REG_RXFTLR, 32)
Expand All @@ -54,6 +51,16 @@ DEFINE_MM_REG_WRITE(dr, DW_SPI_REG_DR, 32)
DEFINE_MM_REG_READ(dr, DW_SPI_REG_DR, 32)
DEFINE_MM_REG_READ(ssi_comp_version, DW_SPI_REG_SSI_COMP_VERSION, 32)

#ifdef CONFIG_SPI_DW_ACCESS_WORD_ONLY
DEFINE_MM_REG_WRITE(ctrlr1, DW_SPI_REG_CTRLR1, 32)
DEFINE_MM_REG_READ(ctrlr1, DW_SPI_REG_CTRLR1, 32)
DEFINE_MM_REG_WRITE(ser, DW_SPI_REG_SER, 32)
#else
DEFINE_MM_REG_WRITE(ctrlr1, DW_SPI_REG_CTRLR1, 16)
DEFINE_MM_REG_READ(ctrlr1, DW_SPI_REG_CTRLR1, 16)
DEFINE_MM_REG_WRITE(ser, DW_SPI_REG_SER, 8)
#endif

/* ICR is on a unique bit */
DEFINE_TEST_BIT_OP(icr, DW_SPI_REG_ICR, DW_SPI_SR_ICR_BIT)
#define clear_interrupts(addr) test_bit_icr(addr)
Expand Down
4 changes: 2 additions & 2 deletions dts/arc/arc_hsdk.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
gpio0: gpio@f0003000 {
compatible = "snps,designware-gpio";
reg = <0xf0003000 0x1000>;
bits = <32>;
bits = <24>;
label = "GPIO_0";
interrupt-parent = <&idu_intc>;

Expand Down Expand Up @@ -181,7 +181,7 @@
#size-cells = <0>;
reg = <0xf0022000 0x1000>;
interrupts = <42 1>;
label = "SPI_1";
label = "SPI_2";
status = "disabled";
};

Expand Down
28 changes: 27 additions & 1 deletion soc/arc/snps_arc_hsdk/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#define IRQ_TIMER1 17
#define IRQ_ICI 19

#define BASE_ADDR_SYSCONFIG 0xF000A000
#define BASE_ADDR_SYSCONFIG 0xF0000000

#define CREG_GPIO_MUX_BASE_ADDR (BASE_ADDR_SYSCONFIG + 0x1484)

#ifndef _ASMLANGUAGE

Expand All @@ -37,6 +39,30 @@
#define DT_UART_NS16550_PORT_1_IRQ_FLAGS 0 /* Default */
#define DT_UART_NS16550_PORT_2_IRQ_FLAGS 0 /* Default */

/* PINMUX IO Hardware Functions */
#define HSDK_PINMUX_FUNS 8

#define HSDK_PINMUX_FUN0 0
#define HSDK_PINMUX_FUN1 1
#define HSDK_PINMUX_FUN2 2
#define HSDK_PINMUX_FUN3 3
#define HSDK_PINMUX_FUN4 4
#define HSDK_PINMUX_FUN5 5
#define HSDK_PINMUX_FUN6 6
#define HSDK_PINMUX_FUN7 7

/* PINMUX MAX SELS */
#define HSDK_PINMUX_SELS 8

#define HSDK_PINMUX_SEL0 0
#define HSDK_PINMUX_SEL1 1
#define HSDK_PINMUX_SEL2 2
#define HSDK_PINMUX_SEL3 3
#define HSDK_PINMUX_SEL4 4
#define HSDK_PINMUX_SEL5 5
#define HSDK_PINMUX_SEL6 6
#define HSDK_PINMUX_SEL7 7


#endif /* !_ASMLANGUAGE */

Expand Down