Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
pinctrl_rcar_common.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 IoT.bzh
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 */
7
8#ifndef ZEPHYR_INCLUDE_DRIVERS_PINCTRL_PINCTRL_RCAR_COMMON_H_
9#define ZEPHYR_INCLUDE_DRIVERS_PINCTRL_PINCTRL_RCAR_COMMON_H_
10
11#include <zephyr/devicetree.h>
13#include <stdint.h>
15
17 uint8_t bank:5; /* bank number 0 - 18 */
18 uint8_t shift:5; /* bit shift 0 - 28 */
19 uint8_t func:4; /* choice from 0x0 to 0xF */
20};
21
23#define RCAR_PIN_FLAGS_PULL_SET BIT(0)
25#define RCAR_PIN_FLAGS_PUEN BIT(1)
27#define RCAR_PIN_FLAGS_PUD BIT(2)
29#define RCAR_PIN_FLAGS_FUNC_SET BIT(3)
31#define RCAR_PIN_FLAGS_FUNC_DUMMY BIT(4)
32
33#define RCAR_PIN_PULL_UP (RCAR_PIN_FLAGS_PULL_SET | RCAR_PIN_FLAGS_PUEN | RCAR_PIN_FLAGS_PUD)
34#define RCAR_PIN_PULL_DOWN (RCAR_PIN_FLAGS_PULL_SET | RCAR_PIN_FLAGS_PUEN)
35#define RCAR_PIN_PULL_DISABLE RCAR_PIN_FLAGS_PULL_SET
36
45
46#define RCAR_HAS_IPSR(node_id) DT_PROP_HAS_IDX(node_id, pin, 1)
47#define RCAR_IPSR(node_id) COND_CODE_1(RCAR_HAS_IPSR(node_id), (DT_PROP_BY_IDX(node_id, pin, 1)), \
48 (0))
49
50/* Offsets are defined in dt-bindings pinctrl-rcar-common.h */
51#define RCAR_PIN_FUNC(node_id) \
52 { \
53 ((RCAR_IPSR(node_id) >> 10U) & 0x1FU), \
54 ((RCAR_IPSR(node_id) >> 4U) & 0x1FU), \
55 ((RCAR_IPSR(node_id) & 0xFU)) \
56 }
57
58#define RCAR_PIN_IS_FUNC_DUMMY(node_id) \
59 ((((RCAR_IPSR(node_id) >> 10U) & 0x1FU) == 0x1F) && \
60 (((RCAR_IPSR(node_id) >> 4U) & 0x1FU) == 0x1F) && \
61 ((RCAR_IPSR(node_id) & 0xFU) == 0xF))
62
63#define RCAR_PIN_FLAGS(node_id) \
64 DT_PROP(node_id, bias_pull_up) * RCAR_PIN_PULL_UP | \
65 DT_PROP(node_id, bias_pull_down) * RCAR_PIN_PULL_DOWN | \
66 DT_PROP(node_id, bias_disable) * RCAR_PIN_PULL_DISABLE | \
67 RCAR_HAS_IPSR(node_id) * RCAR_PIN_FLAGS_FUNC_SET | \
68 RCAR_PIN_IS_FUNC_DUMMY(node_id) * RCAR_PIN_FLAGS_FUNC_DUMMY
69
70#define RCAR_DT_PIN(node_id) \
71 { \
72 .pin = DT_PROP_BY_IDX(node_id, pin, 0), \
73 .func = COND_CODE_1(RCAR_HAS_IPSR(node_id), \
74 (RCAR_PIN_FUNC(node_id)), ({0})), \
75 .flags = RCAR_PIN_FLAGS(node_id), \
76 .drive_strength = \
77 COND_CODE_1(DT_NODE_HAS_PROP(node_id, drive_strength), \
78 (DT_PROP(node_id, drive_strength)), (0)), \
79 .voltage = COND_CODE_1(DT_NODE_HAS_PROP(node_id, \
80 power_source), \
81 (DT_PROP(node_id, power_source)), \
82 (PIN_VOLTAGE_NONE)), \
83 },
84
92#define Z_PINCTRL_STATE_PIN_INIT(node_id, state_prop, idx) \
93 RCAR_DT_PIN(DT_PROP_BY_IDX(node_id, state_prop, idx))
94
101#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \
102 { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) }
103
109
114
120
127#define RCAR_IS_GP_PIN(pin) (pin < PIN_NOGPSR_START)
128
129#endif /* ZEPHYR_INCLUDE_DRIVERS_PINCTRL_PINCTRL_RCAR_COMMON_H_ */
Devicetree main header.
Devicetree pin control helpers for Renesas R-Car.
struct pinctrl_soc_pin pinctrl_soc_pin_t
Type for R-Car pin.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Type for R-Car bias registers.
Definition pinctrl_rcar_common.h:115
const uint16_t pins[32]
Pull-up/down or pull-down control register.
Definition pinctrl_rcar_common.h:118
uint32_t pud
Pull-enable or pull-up control register.
Definition pinctrl_rcar_common.h:117
uint32_t puen
Pull-enable register.
Definition pinctrl_rcar_common.h:116
Definition pinctrl_rcar_common.h:104
uint16_t pin
Definition pinctrl_rcar_common.h:105
uint8_t size
Definition pinctrl_rcar_common.h:107
uint8_t offset
Definition pinctrl_rcar_common.h:106
Type for R-Car DRVCTRLn registers.
Definition pinctrl_rcar_common.h:110
const struct pfc_drive_reg_field fields[8]
Definition pinctrl_rcar_common.h:112
uint32_t reg
Definition pinctrl_rcar_common.h:111
Type for R-Car pin.
Definition pinctrl_rcar_common.h:38
uint8_t drive_strength
Definition pinctrl_rcar_common.h:42
uint16_t pin
Pin ID.
Definition pinctrl_rcar_common.h:39
uint8_t voltage
Definition pinctrl_rcar_common.h:43
uint8_t flags
Flags (bias and pin mode).
Definition pinctrl_rcar_common.h:41
struct rcar_pin_func func
Pin function.
Definition pinctrl_rcar_common.h:40
Type for R-Car pin function.
Definition pinctrl_rcar_common.h:16
uint8_t bank
Definition pinctrl_rcar_common.h:17
uint8_t shift
Definition pinctrl_rcar_common.h:18
uint8_t func
Alternate function 0 - 15.
Definition pinctrl_rcar_common.h:19
Macro utilities.