Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Renesas RPC-IF core driver
0004  *
0005  * Copyright (C) 2018~2019 Renesas Solutions Corp.
0006  * Copyright (C) 2019 Macronix International Co., Ltd.
0007  * Copyright (C) 2019-2020 Cogent Embedded, Inc.
0008  */
0009 
0010 #ifndef __RENESAS_RPC_IF_H
0011 #define __RENESAS_RPC_IF_H
0012 
0013 #include <linux/pm_runtime.h>
0014 #include <linux/types.h>
0015 
0016 enum rpcif_data_dir {
0017     RPCIF_NO_DATA,
0018     RPCIF_DATA_IN,
0019     RPCIF_DATA_OUT,
0020 };
0021 
0022 struct rpcif_op {
0023     struct {
0024         u8 buswidth;
0025         u8 opcode;
0026         bool ddr;
0027     } cmd, ocmd;
0028 
0029     struct {
0030         u8 nbytes;
0031         u8 buswidth;
0032         bool ddr;
0033         u64 val;
0034     } addr;
0035 
0036     struct {
0037         u8 ncycles;
0038         u8 buswidth;
0039     } dummy;
0040 
0041     struct {
0042         u8 nbytes;
0043         u8 buswidth;
0044         bool ddr;
0045         u32 val;
0046     } option;
0047 
0048     struct {
0049         u8 buswidth;
0050         unsigned int nbytes;
0051         enum rpcif_data_dir dir;
0052         bool ddr;
0053         union {
0054             void *in;
0055             const void *out;
0056         } buf;
0057     } data;
0058 };
0059 
0060 enum rpcif_type {
0061     RPCIF_RCAR_GEN3,
0062     RPCIF_RZ_G2L,
0063 };
0064 
0065 struct rpcif {
0066     struct device *dev;
0067     void __iomem *base;
0068     void __iomem *dirmap;
0069     struct regmap *regmap;
0070     struct reset_control *rstc;
0071     size_t size;
0072     enum rpcif_type type;
0073     enum rpcif_data_dir dir;
0074     u8 bus_size;
0075     u8 xfer_size;
0076     void *buffer;
0077     u32 xferlen;
0078     u32 smcr;
0079     u32 smadr;
0080     u32 command;        /* DRCMR or SMCMR */
0081     u32 option;     /* DROPR or SMOPR */
0082     u32 enable;     /* DRENR or SMENR */
0083     u32 dummy;      /* DRDMCR or SMDMCR */
0084     u32 ddr;        /* DRDRENR or SMDRENR */
0085 };
0086 
0087 int rpcif_sw_init(struct rpcif *rpc, struct device *dev);
0088 int rpcif_hw_init(struct rpcif *rpc, bool hyperflash);
0089 void rpcif_prepare(struct rpcif *rpc, const struct rpcif_op *op, u64 *offs,
0090            size_t *len);
0091 int rpcif_manual_xfer(struct rpcif *rpc);
0092 ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf);
0093 
0094 static inline void rpcif_enable_rpm(struct rpcif *rpc)
0095 {
0096     pm_runtime_enable(rpc->dev);
0097 }
0098 
0099 static inline void rpcif_disable_rpm(struct rpcif *rpc)
0100 {
0101     pm_runtime_disable(rpc->dev);
0102 }
0103 
0104 #endif // __RENESAS_RPC_IF_H