Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
662 changes: 662 additions & 0 deletions arch/risc-v/include/eic7700x/eic7700x_pinctrl.h

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion arch/risc-v/src/eic7700x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,21 @@ config EIC7700X_CPU_FREQ_MHZ
cores at 1400, so the default changes nothing and merely says
so in the log.

endif
endif

config EIC7700X_PINCTRL
bool "CLMM pad multiplexing"
default y
select PINCTRL
---help---
Describe the pads of the Chip Level Mode Mux (CLMM) to the NuttX
pinctrl framework. Initialisation writes nothing to the hardware:
a pad only moves when a driver asks it to.

Every pad on the SoC shares its ball with something else, so the
UARTs beyond the console, the GPIO block and the peripheral buses
all need a pad configured here before they reach a pin.

The board reports the pad count and how many differ from their
reset defaults once, at startup. With DEBUG_PINCTRL_INFO the
driver also logs each pad as it is configured.
4 changes: 4 additions & 0 deletions arch/risc-v/src/eic7700x/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ endif
ifeq ($(CONFIG_EIC7700X_CPUCLK),y)
CHIP_CSRCS += eic7700x_cpuclk.c
endif

ifeq ($(CONFIG_EIC7700X_PINCTRL),y)
CHIP_CSRCS += eic7700x_pinctrl.c eic7700x_pinctrl_ops.c
endif
836 changes: 836 additions & 0 deletions arch/risc-v/src/eic7700x/eic7700x_pinctrl.c

Large diffs are not rendered by default.

250 changes: 250 additions & 0 deletions arch/risc-v/src/eic7700x/eic7700x_pinctrl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
/****************************************************************************
* arch/risc-v/src/eic7700x/eic7700x_pinctrl.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

#ifndef __ARCH_RISCV_SRC_EIC7700X_EIC7700X_PINCTRL_H
#define __ARCH_RISCV_SRC_EIC7700X_EIC7700X_PINCTRL_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

#include <stdint.h>

#include <nuttx/pinctrl/pinctrl.h>

#include <arch/chip/eic7700x_pinctrl.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/* Whether anything wants a pad's name in text. The names cost about nine
* kilobytes, so they are only compiled when something will print them.
* GPIO_PROCFS is a consumer to come: the GPIO driver's procfs entry names
* the pad behind each line.
*/

#if defined(CONFIG_PINCTRL_PROCFS) || defined(CONFIG_GPIO_PROCFS)
# define HAVE_PINCTRL_TEXT 1
#endif

/* How many distinct reset values the 166 pads have between them. The
* manual gives a reset value per field; reassembled into words they
* collapse to this many, so the table stores an index instead of a word.
*/

#define EIC7700X_PAD_NDEFAULTS (15)

/* How many GPIO lines the SoC has. Two of them, 5 and 11, are balls in
* part 1 table 2-4 that the register detail description gives no pad
* register for, so the reverse map below has holes there.
*/

#define EIC7700X_PAD_NGPIOS (112)
#define EIC7700X_PAD_NOPAD (0xff)

/* A pad's gpiofunc when the pad offers no GPIO function at all. */

#define EIC7700X_PAD_NOGPIO (0xff)

/* Pad flags */

#define EIC7700X_PAD_LOCKED (1 << 0) /* Refuses to be written */

/****************************************************************************
* Public Types
****************************************************************************/

/* Which of the four field layouts a pad uses. See the layout notes in
* hardware/eic7700x_pinctrl.h: the same bit means different things, or
* nothing, depending on this.
*/

enum eic7700x_padshape_e
{
EIC7700X_PADSHAPE_GENERAL = 0, /* Function select, pull, drive, input */
EIC7700X_PADSHAPE_RGMII, /* Voltage mode instead of function */
EIC7700X_PADSHAPE_OSC, /* Drive, damping and feedback only */
EIC7700X_PADSHAPE_MODESEL /* Group voltage select, carries no pin */
};

/* One pad register.
*
* wmask comes straight from the access column of the manual's register
* detail description, one bit per writable register bit. It is the only
* thing standing between a caller and a write the hardware will ignore,
* and five pads have it zero: the hardware reports their state and nothing
* more.
*/

struct eic7700x_pad_s
{
uint32_t wmask; /* Bits the hardware will let software drive */
uint8_t shape; /* enum eic7700x_padshape_e */
uint8_t dflt; /* Index into g_eic7700x_pad_defaults[] */
uint8_t funcmask; /* Bit n set: function select n is documented */
uint8_t gpiofunc; /* Function select giving GPIO, or NOGPIO */
uint8_t flags; /* EIC7700X_PAD_* flags */
};

/****************************************************************************
* Public Data
****************************************************************************/

#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif

EXTERN const struct eic7700x_pad_s
g_eic7700x_pads[EIC7700X_PAD_NPADS];
EXTERN const uint32_t
g_eic7700x_pad_defaults[EIC7700X_PAD_NDEFAULTS];
EXTERN const uint8_t
g_eic7700x_pad_bygpio[EIC7700X_PAD_NGPIOS];
EXTERN const struct pinctrl_ops_s g_eic7700x_pinctrl_ops;

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

/****************************************************************************
* Name: eic7700x_pinctrl_initialize
*
* Description:
* Bring up the pad multiplexing block. This writes nothing to the
* hardware: a pad only moves when a driver asks it to.
*
* Returned Value:
* OK on success, or a negated errno on failure.
*
****************************************************************************/

int eic7700x_pinctrl_initialize(void);

/****************************************************************************
* Name: eic7700x_pinctrl_count
*
* Description:
* How many pads the block has, and through changed how many currently
* differ from their reset defaults.
*
* Input Parameters:
* changed - Receives the changed-pad count; may be NULL.
*
* Returned Value:
* The number of pads.
*
****************************************************************************/

unsigned int eic7700x_pinctrl_count(FAR unsigned int *changed);

/****************************************************************************
* Name: eic7700x_pad_name
*
* Description:
* The manual's name for a pad.
*
* Input Parameters:
* pad - The pad id, an enum eic7700x_pad_e value
*
* Returned Value:
* The name, or NULL if the pad id is out of range or the name tables
* are not built.
*
****************************************************************************/

FAR const char *eic7700x_pad_name(unsigned int pad);

/****************************************************************************
* Name: eic7700x_pad_funcname
*
* Description:
* The name of one of a pad's function selects.
*
* Input Parameters:
* pad - The pad id, an enum eic7700x_pad_e value
* func - The function select
*
* Returned Value:
* The name, or NULL if the manual does not document that select or the
* name tables are not built.
*
****************************************************************************/

FAR const char *eic7700x_pad_funcname(unsigned int pad, unsigned int func);

/****************************************************************************
* Name: eic7700x_pad_lookup
*
* Description:
* Bound a pad id and return the row describing it. Nothing else in this
* driver may index the pad table directly: this is the single place an
* out of range id is caught.
*
* Input Parameters:
* pad - The pad id, an enum eic7700x_pad_e value
*
* Returned Value:
* The pad description, or NULL if the id names no pad.
*
****************************************************************************/

FAR const struct eic7700x_pad_s *eic7700x_pad_lookup(unsigned int pad);

/****************************************************************************
* Name: eic7700x_pad_config
*
* Description:
* Configure one pad. The value is a whole pad register, built from the
* PINCTRL_* field macros for the layout the pad uses, and every field
* lands in a single write so that a pad is never briefly half
* configured. Bits the hardware will not let software drive keep the
* value they already had.
*
* Input Parameters:
* pad - The pad id, an enum eic7700x_pad_e value
* cfg - The register value to install
*
* Returned Value:
* OK on success, or a negated errno:
*
* -EINVAL the id names no pad, or the value selects a function the
* manual does not document for this pad
* -EROFS the value tries to drive a bit that reports state only
* -EPERM the pad is one this driver refuses to move
*
****************************************************************************/

int eic7700x_pad_config(unsigned int pad, uint32_t cfg);

#undef EXTERN
#ifdef __cplusplus
}
#endif

#endif /* __ARCH_RISCV_SRC_EIC7700X_EIC7700X_PINCTRL_H */
Loading
Loading