Skip to content

Commit

Permalink
driver: mcux_rgpio: enable runtime mmio configuration
Browse files Browse the repository at this point in the history
Enable runtime mmio configuration in mcux_rgpio driver. Remove mmu
region definition in mimx9/mmu_region.c

Signed-off-by: Chekhov Ma <[email protected]>
  • Loading branch information
CkovMk committed Dec 5, 2023
1 parent 32feea8 commit 8ecff4d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
27 changes: 26 additions & 1 deletion drivers/gpio/gpio_mcux_rgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@ struct gpio_pin_gaps {
uint8_t len;
};

#ifdef CONFIG_MMU
/* Required by DEVICE_MMIO_NAMED_* macros */
#define DEV_CFG(_dev) \
((const struct mcux_rgpio_config *)(_dev)->config)
#define DEV_DATA(_dev) ((struct mcux_rgpio_data *)(_dev)->data)
#endif /* CONFIG_MMU */

struct mcux_rgpio_config {
/* gpio_driver_config needs to be first */
struct gpio_driver_config common;
#ifdef CONFIG_MMU
DEVICE_MMIO_NAMED_ROM(reg_base);
#else /* CONFIG_MMU */
RGPIO_Type *base;

Check failure on line 40 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACING

drivers/gpio/gpio_mcux_rgpio.c:40 need consistent spacing around '*' (ctx:WxV)
#endif /* CONFIG_MMU */
#ifdef CONFIG_PINCTRL
const struct pinctrl_soc_pinmux *pin_muxes;
const struct gpio_pin_gaps *pin_gaps;
Expand All @@ -39,14 +50,21 @@ struct mcux_rgpio_config {
struct mcux_rgpio_data {
/* gpio_driver_data needs to be first */
struct gpio_driver_data general;
#ifdef CONFIG_MMU
DEVICE_MMIO_NAMED_RAM(reg_base);
#endif /* CONFIG_MMU */
/* port ISR callback routine address */
sys_slist_t callbacks;
};

static inline RGPIO_Type* mcux_rgpio_get_base_addr(const struct device *dev)

Check failure on line 60 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

POINTER_LOCATION

drivers/gpio/gpio_mcux_rgpio.c:60 "foo* bar" should be "foo *bar"
{
#ifdef CONFIG_MMU
return (RGPIO_Type*)DEVICE_MMIO_NAMED_GET(dev, reg_base);

Check failure on line 63 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

POINTER_LOCATION

drivers/gpio/gpio_mcux_rgpio.c:63 "(foo*)" should be "(foo *)"
#else /* CONFIG_MMU */
const struct mcux_rgpio_config *config = dev->config;
return config->base;

Check warning on line 66 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LINE_SPACING

drivers/gpio/gpio_mcux_rgpio.c:66 Missing a blank line after declarations
#endif /* CONFIG_MMU */
}

static int mcux_rgpio_configure(const struct device *dev,
Expand Down Expand Up @@ -293,7 +311,11 @@ static const struct gpio_driver_api mcux_rgpio_driver_api = {
.common = { \
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n),\
}, \
.base = (RGPIO_Type *)DT_INST_REG_ADDR(n), \
COND_CODE_1(CONFIG_MMU, ( \
DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)) /** true */ \

Check failure on line 315 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

drivers/gpio/gpio_mcux_rgpio.c:315 code indent should use tabs where possible

Check warning on line 315 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

drivers/gpio/gpio_mcux_rgpio.c:315 please, no space before tabs

Check warning on line 315 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

drivers/gpio/gpio_mcux_rgpio.c:315 please, no spaces at the start of a line
), ( \

Check failure on line 316 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

drivers/gpio/gpio_mcux_rgpio.c:316 code indent should use tabs where possible
.base = (RGPIO_Type *) DT_INST_REG_ADDR(n) /** false */ \

Check failure on line 317 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

drivers/gpio/gpio_mcux_rgpio.c:317 code indent should use tabs where possible
)), \

Check failure on line 318 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

drivers/gpio/gpio_mcux_rgpio.c:318 code indent should use tabs where possible
MCUX_RGPIO_PIN_INIT(n) \
}; \
\
Expand All @@ -310,6 +332,9 @@ static const struct gpio_driver_api mcux_rgpio_driver_api = {
\
static int mcux_rgpio_##n##_init(const struct device *dev) \
{ \
IF_ENABLED(CONFIG_MMU, ( \
DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP) \

Check failure on line 336 in drivers/gpio/gpio_mcux_rgpio.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

drivers/gpio/gpio_mcux_rgpio.c:336 code indent should use tabs where possible
)); \
IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), \
(MCUX_RGPIO_IRQ_INIT(n, 0);)) \
\
Expand Down
20 changes: 0 additions & 20 deletions soc/arm64/nxp_imx/mimx9/mmu_regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,6 @@ static const struct arm_mmu_region mmu_regions[] = {
DT_REG_ADDR(DT_NODELABEL(iomuxc)),
DT_REG_SIZE(DT_NODELABEL(iomuxc)),
MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_NS),

MMU_REGION_FLAT_ENTRY("GPIO1",
DT_REG_ADDR(DT_NODELABEL(gpio1)),
DT_REG_SIZE(DT_NODELABEL(gpio1)),
MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_NS),

MMU_REGION_FLAT_ENTRY("GPIO2",
DT_REG_ADDR(DT_NODELABEL(gpio2)),
DT_REG_SIZE(DT_NODELABEL(gpio2)),
MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_NS),

MMU_REGION_FLAT_ENTRY("GPIO3",
DT_REG_ADDR(DT_NODELABEL(gpio3)),
DT_REG_SIZE(DT_NODELABEL(gpio3)),
MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_NS),

MMU_REGION_FLAT_ENTRY("GPIO4",
DT_REG_ADDR(DT_NODELABEL(gpio4)),
DT_REG_SIZE(DT_NODELABEL(gpio4)),
MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_NS),
#if CONFIG_SOF
MMU_REGION_FLAT_ENTRY("MU2_A",
DT_REG_ADDR(DT_NODELABEL(mu2_a)),
Expand Down

0 comments on commit 8ecff4d

Please sign in to comment.