89 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * PRU-ICSS Subsystem user interfaces4 *5 * Copyright (C) 2015-2023 Texas Instruments Incorporated - http://www.ti.com6 * MD Danish Anwar <danishanwar@ti.com>7 */8 9#ifndef _SOC_TI_PRUSS_H_10#define _SOC_TI_PRUSS_H_11 12#include <linux/bits.h>13#include <linux/regmap.h>14 15/*16 * PRU_ICSS_CFG registers17 * SYSCFG, ISRP, ISP, IESP, IECP, SCRP applicable on AMxxxx devices only18 */19#define PRUSS_CFG_REVID 0x0020#define PRUSS_CFG_SYSCFG 0x0421#define PRUSS_CFG_GPCFG(x) (0x08 + (x) * 4)22#define PRUSS_CFG_CGR 0x1023#define PRUSS_CFG_ISRP 0x1424#define PRUSS_CFG_ISP 0x1825#define PRUSS_CFG_IESP 0x1C26#define PRUSS_CFG_IECP 0x2027#define PRUSS_CFG_SCRP 0x2428#define PRUSS_CFG_PMAO 0x2829#define PRUSS_CFG_MII_RT 0x2C30#define PRUSS_CFG_IEPCLK 0x3031#define PRUSS_CFG_SPP 0x3432#define PRUSS_CFG_PIN_MX 0x4033 34/* PRUSS_GPCFG register bits */35#define PRUSS_GPCFG_PRU_GPI_MODE_MASK GENMASK(1, 0)36#define PRUSS_GPCFG_PRU_GPI_MODE_SHIFT 037 38#define PRUSS_GPCFG_PRU_MUX_SEL_SHIFT 2639#define PRUSS_GPCFG_PRU_MUX_SEL_MASK GENMASK(29, 26)40 41/* PRUSS_MII_RT register bits */42#define PRUSS_MII_RT_EVENT_EN BIT(0)43 44/* PRUSS_SPP register bits */45#define PRUSS_SPP_XFER_SHIFT_EN BIT(1)46#define PRUSS_SPP_PRU1_PAD_HP_EN BIT(0)47#define PRUSS_SPP_RTU_XFR_SHIFT_EN BIT(3)48 49/**50 * pruss_cfg_read() - read a PRUSS CFG sub-module register51 * @pruss: the pruss instance handle52 * @reg: register offset within the CFG sub-module53 * @val: pointer to return the value in54 *55 * Reads a given register within the PRUSS CFG sub-module and56 * returns it through the passed-in @val pointer57 *58 * Return: 0 on success, or an error code otherwise59 */60static int pruss_cfg_read(struct pruss *pruss, unsigned int reg, unsigned int *val)61{62 if (IS_ERR_OR_NULL(pruss))63 return -EINVAL;64 65 return regmap_read(pruss->cfg_regmap, reg, val);66}67 68/**69 * pruss_cfg_update() - configure a PRUSS CFG sub-module register70 * @pruss: the pruss instance handle71 * @reg: register offset within the CFG sub-module72 * @mask: bit mask to use for programming the @val73 * @val: value to write74 *75 * Programs a given register within the PRUSS CFG sub-module76 *77 * Return: 0 on success, or an error code otherwise78 */79static int pruss_cfg_update(struct pruss *pruss, unsigned int reg,80 unsigned int mask, unsigned int val)81{82 if (IS_ERR_OR_NULL(pruss))83 return -EINVAL;84 85 return regmap_update_bits(pruss->cfg_regmap, reg, mask, val);86}87 88#endif /* _SOC_TI_PRUSS_H_ */89