1 /* SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/
6 #ifndef __LINUX_MTD_HYPERBUS_H__
7 #define __LINUX_MTD_HYPERBUS_H__
9 #include <linux/mtd/map.h>
11 /* HyperBus command bits */
12 #define HYPERBUS_RW 0x80 /* R/W# */
13 #define HYPERBUS_RW_WRITE 0
14 #define HYPERBUS_RW_READ 0x80
15 #define HYPERBUS_AS 0x40 /* Address Space */
16 #define HYPERBUS_AS_MEM 0
17 #define HYPERBUS_AS_REG 0x40
18 #define HYPERBUS_BT 0x20 /* Burst Type */
19 #define HYPERBUS_BT_WRAPPED 0
20 #define HYPERBUS_BT_LINEAR 0x20
22 enum hyperbus_memtype
{
28 * struct hyperbus_device - struct representing HyperBus slave device
29 * @map: map_info struct for accessing MMIO HyperBus flash memory
30 * @np: pointer to HyperBus slave device node
31 * @mtd: pointer to MTD struct
32 * @ctlr: pointer to HyperBus controller struct
33 * @memtype: type of memory device: HyperFlash or HyperRAM
34 * @priv: pointer to controller specific per device private data
37 struct hyperbus_device
{
39 struct device_node
*np
;
41 struct hyperbus_ctlr
*ctlr
;
42 enum hyperbus_memtype memtype
;
47 * struct hyperbus_ops - struct representing custom HyperBus operations
48 * @read16: read 16 bit of data from flash in a single burst. Used to read
49 * from non default address space, such as ID/CFI space
50 * @write16: write 16 bit of data to flash in a single burst. Used to
51 * send cmd to flash or write single 16 bit word at a time.
52 * @copy_from: copy data from flash memory
53 * @copy_to: copy data to flash memory
54 * @calibrate: calibrate HyperBus controller
58 u16 (*read16
)(struct hyperbus_device
*hbdev
, unsigned long addr
);
59 void (*write16
)(struct hyperbus_device
*hbdev
,
60 unsigned long addr
, u16 val
);
61 void (*copy_from
)(struct hyperbus_device
*hbdev
, void *to
,
62 unsigned long from
, ssize_t len
);
63 void (*copy_to
)(struct hyperbus_device
*dev
, unsigned long to
,
64 const void *from
, ssize_t len
);
65 int (*calibrate
)(struct hyperbus_device
*dev
);
69 * struct hyperbus_ctlr - struct representing HyperBus controller
70 * @dev: pointer to HyperBus controller device
71 * @calibrated: flag to indicate ctlr calibration sequence is complete
72 * @ops: HyperBus controller ops
74 struct hyperbus_ctlr
{
78 const struct hyperbus_ops
*ops
;
82 * hyperbus_register_device - probe and register a HyperBus slave memory device
83 * @hbdev: hyperbus_device struct with dev, np and ctlr field populated
85 * Return: 0 for success, others for failure.
87 int hyperbus_register_device(struct hyperbus_device
*hbdev
);
90 * hyperbus_unregister_device - deregister HyperBus slave memory device
91 * @hbdev: hyperbus_device to be unregistered
93 void hyperbus_unregister_device(struct hyperbus_device
*hbdev
);
95 #endif /* __LINUX_MTD_HYPERBUS_H__ */