1*1a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2efa2ca73SRobert Jarzmik /* 3efa2ca73SRobert Jarzmik * Handles the M-Systems DiskOnChip G3 chip 4efa2ca73SRobert Jarzmik * 5efa2ca73SRobert Jarzmik * Copyright (C) 2011 Robert Jarzmik 6efa2ca73SRobert Jarzmik */ 7efa2ca73SRobert Jarzmik 8efa2ca73SRobert Jarzmik #ifndef _MTD_DOCG3_H 9efa2ca73SRobert Jarzmik #define _MTD_DOCG3_H 10efa2ca73SRobert Jarzmik 111b15a5f9SRobert Jarzmik #include <linux/mtd/mtd.h> 121b15a5f9SRobert Jarzmik 13efa2ca73SRobert Jarzmik /* 14efa2ca73SRobert Jarzmik * Flash memory areas : 15efa2ca73SRobert Jarzmik * - 0x0000 .. 0x07ff : IPL 16efa2ca73SRobert Jarzmik * - 0x0800 .. 0x0fff : Data area 17efa2ca73SRobert Jarzmik * - 0x1000 .. 0x17ff : Registers 18efa2ca73SRobert Jarzmik * - 0x1800 .. 0x1fff : Unknown 19efa2ca73SRobert Jarzmik */ 20efa2ca73SRobert Jarzmik #define DOC_IOSPACE_IPL 0x0000 21efa2ca73SRobert Jarzmik #define DOC_IOSPACE_DATA 0x0800 22efa2ca73SRobert Jarzmik #define DOC_IOSPACE_SIZE 0x2000 23efa2ca73SRobert Jarzmik 24efa2ca73SRobert Jarzmik /* 25efa2ca73SRobert Jarzmik * DOC G3 layout and adressing scheme 26efa2ca73SRobert Jarzmik * A page address for the block "b", plane "P" and page "p": 27efa2ca73SRobert Jarzmik * address = [bbbb bPpp pppp] 28efa2ca73SRobert Jarzmik */ 29efa2ca73SRobert Jarzmik 30efa2ca73SRobert Jarzmik #define DOC_ADDR_PAGE_MASK 0x3f 31efa2ca73SRobert Jarzmik #define DOC_ADDR_BLOCK_SHIFT 6 32efa2ca73SRobert Jarzmik #define DOC_LAYOUT_NBPLANES 2 33efa2ca73SRobert Jarzmik #define DOC_LAYOUT_PAGES_PER_BLOCK 64 34efa2ca73SRobert Jarzmik #define DOC_LAYOUT_PAGE_SIZE 512 35efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_SIZE 16 36efa2ca73SRobert Jarzmik #define DOC_LAYOUT_WEAR_SIZE 8 37efa2ca73SRobert Jarzmik #define DOC_LAYOUT_PAGE_OOB_SIZE \ 38efa2ca73SRobert Jarzmik (DOC_LAYOUT_PAGE_SIZE + DOC_LAYOUT_OOB_SIZE) 39efa2ca73SRobert Jarzmik #define DOC_LAYOUT_WEAR_OFFSET (DOC_LAYOUT_PAGE_OOB_SIZE * 2) 40efa2ca73SRobert Jarzmik #define DOC_LAYOUT_BLOCK_SIZE \ 41efa2ca73SRobert Jarzmik (DOC_LAYOUT_PAGES_PER_BLOCK * DOC_LAYOUT_PAGE_SIZE) 42d13d19ecSRobert Jarzmik 43d13d19ecSRobert Jarzmik /* 44d13d19ecSRobert Jarzmik * ECC related constants 45d13d19ecSRobert Jarzmik */ 46d13d19ecSRobert Jarzmik #define DOC_ECC_BCH_M 14 47d13d19ecSRobert Jarzmik #define DOC_ECC_BCH_T 4 48d13d19ecSRobert Jarzmik #define DOC_ECC_BCH_PRIMPOLY 0x4443 49efa2ca73SRobert Jarzmik #define DOC_ECC_BCH_SIZE 7 50efa2ca73SRobert Jarzmik #define DOC_ECC_BCH_COVERED_BYTES \ 51efa2ca73SRobert Jarzmik (DOC_LAYOUT_PAGE_SIZE + DOC_LAYOUT_OOB_PAGEINFO_SZ + \ 52d13d19ecSRobert Jarzmik DOC_LAYOUT_OOB_HAMMING_SZ) 53d13d19ecSRobert Jarzmik #define DOC_ECC_BCH_TOTAL_BYTES \ 54d13d19ecSRobert Jarzmik (DOC_ECC_BCH_COVERED_BYTES + DOC_LAYOUT_OOB_BCH_SZ) 55efa2ca73SRobert Jarzmik 56efa2ca73SRobert Jarzmik /* 57efa2ca73SRobert Jarzmik * Blocks distribution 58efa2ca73SRobert Jarzmik */ 59efa2ca73SRobert Jarzmik #define DOC_LAYOUT_BLOCK_BBT 0 60efa2ca73SRobert Jarzmik #define DOC_LAYOUT_BLOCK_OTP 0 61efa2ca73SRobert Jarzmik #define DOC_LAYOUT_BLOCK_FIRST_DATA 6 62efa2ca73SRobert Jarzmik 63efa2ca73SRobert Jarzmik #define DOC_LAYOUT_PAGE_BBT 4 64efa2ca73SRobert Jarzmik 65efa2ca73SRobert Jarzmik /* 66efa2ca73SRobert Jarzmik * Extra page OOB (16 bytes wide) layout 67efa2ca73SRobert Jarzmik */ 68efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_PAGEINFO_OFS 0 69efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_HAMMING_OFS 7 70efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_BCH_OFS 8 71efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_UNUSED_OFS 15 72efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_PAGEINFO_SZ 7 73efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_HAMMING_SZ 1 74efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_BCH_SZ 7 75efa2ca73SRobert Jarzmik #define DOC_LAYOUT_OOB_UNUSED_SZ 1 76efa2ca73SRobert Jarzmik 77efa2ca73SRobert Jarzmik 78efa2ca73SRobert Jarzmik #define DOC_CHIPID_G3 0x200 79efa2ca73SRobert Jarzmik #define DOC_ERASE_MARK 0xaa 80ae9d4934SRobert Jarzmik #define DOC_MAX_NBFLOORS 4 81efa2ca73SRobert Jarzmik /* 82efa2ca73SRobert Jarzmik * Flash registers 83efa2ca73SRobert Jarzmik */ 84efa2ca73SRobert Jarzmik #define DOC_CHIPID 0x1000 85efa2ca73SRobert Jarzmik #define DOC_TEST 0x1004 86efa2ca73SRobert Jarzmik #define DOC_BUSLOCK 0x1006 87efa2ca73SRobert Jarzmik #define DOC_ENDIANCONTROL 0x1008 88efa2ca73SRobert Jarzmik #define DOC_DEVICESELECT 0x100a 89efa2ca73SRobert Jarzmik #define DOC_ASICMODE 0x100c 90efa2ca73SRobert Jarzmik #define DOC_CONFIGURATION 0x100e 91efa2ca73SRobert Jarzmik #define DOC_INTERRUPTCONTROL 0x1010 92efa2ca73SRobert Jarzmik #define DOC_READADDRESS 0x101a 93efa2ca73SRobert Jarzmik #define DOC_DATAEND 0x101e 94efa2ca73SRobert Jarzmik #define DOC_INTERRUPTSTATUS 0x1020 95efa2ca73SRobert Jarzmik 96efa2ca73SRobert Jarzmik #define DOC_FLASHSEQUENCE 0x1032 97efa2ca73SRobert Jarzmik #define DOC_FLASHCOMMAND 0x1034 98efa2ca73SRobert Jarzmik #define DOC_FLASHADDRESS 0x1036 99efa2ca73SRobert Jarzmik #define DOC_FLASHCONTROL 0x1038 100efa2ca73SRobert Jarzmik #define DOC_NOP 0x103e 101efa2ca73SRobert Jarzmik 102efa2ca73SRobert Jarzmik #define DOC_ECCCONF0 0x1040 103efa2ca73SRobert Jarzmik #define DOC_ECCCONF1 0x1042 104efa2ca73SRobert Jarzmik #define DOC_ECCPRESET 0x1044 105efa2ca73SRobert Jarzmik #define DOC_HAMMINGPARITY 0x1046 106b604436cSRobert Jarzmik #define DOC_BCH_HW_ECC(idx) (0x1048 + idx) 107efa2ca73SRobert Jarzmik 108efa2ca73SRobert Jarzmik #define DOC_PROTECTION 0x1056 1090f769d3fSRobert Jarzmik #define DOC_DPS0_KEY 0x105c 1100f769d3fSRobert Jarzmik #define DOC_DPS1_KEY 0x105e 111efa2ca73SRobert Jarzmik #define DOC_DPS0_ADDRLOW 0x1060 112efa2ca73SRobert Jarzmik #define DOC_DPS0_ADDRHIGH 0x1062 113efa2ca73SRobert Jarzmik #define DOC_DPS1_ADDRLOW 0x1064 114efa2ca73SRobert Jarzmik #define DOC_DPS1_ADDRHIGH 0x1066 115efa2ca73SRobert Jarzmik #define DOC_DPS0_STATUS 0x106c 116efa2ca73SRobert Jarzmik #define DOC_DPS1_STATUS 0x106e 117efa2ca73SRobert Jarzmik 118efa2ca73SRobert Jarzmik #define DOC_ASICMODECONFIRM 0x1072 119efa2ca73SRobert Jarzmik #define DOC_CHIPID_INV 0x1074 120e4b2a96aSRobert Jarzmik #define DOC_POWERMODE 0x107c 121efa2ca73SRobert Jarzmik 122efa2ca73SRobert Jarzmik /* 123efa2ca73SRobert Jarzmik * Flash sequences 124efa2ca73SRobert Jarzmik * A sequence is preset before one or more commands are input to the chip. 125efa2ca73SRobert Jarzmik */ 126efa2ca73SRobert Jarzmik #define DOC_SEQ_RESET 0x00 127efa2ca73SRobert Jarzmik #define DOC_SEQ_PAGE_SIZE_532 0x03 128c3de8a8aSRobert Jarzmik #define DOC_SEQ_SET_FASTMODE 0x05 129c3de8a8aSRobert Jarzmik #define DOC_SEQ_SET_RELIABLEMODE 0x09 130efa2ca73SRobert Jarzmik #define DOC_SEQ_READ 0x12 131efa2ca73SRobert Jarzmik #define DOC_SEQ_SET_PLANE1 0x0e 132efa2ca73SRobert Jarzmik #define DOC_SEQ_SET_PLANE2 0x10 133efa2ca73SRobert Jarzmik #define DOC_SEQ_PAGE_SETUP 0x1d 134376fbf20SRobert Jarzmik #define DOC_SEQ_ERASE 0x27 135376fbf20SRobert Jarzmik #define DOC_SEQ_PLANES_STATUS 0x31 136efa2ca73SRobert Jarzmik 137efa2ca73SRobert Jarzmik /* 138efa2ca73SRobert Jarzmik * Flash commands 139efa2ca73SRobert Jarzmik */ 140efa2ca73SRobert Jarzmik #define DOC_CMD_READ_PLANE1 0x00 141efa2ca73SRobert Jarzmik #define DOC_CMD_SET_ADDR_READ 0x05 142efa2ca73SRobert Jarzmik #define DOC_CMD_READ_ALL_PLANES 0x30 143efa2ca73SRobert Jarzmik #define DOC_CMD_READ_PLANE2 0x50 144efa2ca73SRobert Jarzmik #define DOC_CMD_READ_FLASH 0xe0 145efa2ca73SRobert Jarzmik #define DOC_CMD_PAGE_SIZE_532 0x3c 146efa2ca73SRobert Jarzmik 147efa2ca73SRobert Jarzmik #define DOC_CMD_PROG_BLOCK_ADDR 0x60 148efa2ca73SRobert Jarzmik #define DOC_CMD_PROG_CYCLE1 0x80 149efa2ca73SRobert Jarzmik #define DOC_CMD_PROG_CYCLE2 0x10 150376fbf20SRobert Jarzmik #define DOC_CMD_PROG_CYCLE3 0x11 151efa2ca73SRobert Jarzmik #define DOC_CMD_ERASECYCLE2 0xd0 152376fbf20SRobert Jarzmik #define DOC_CMD_READ_STATUS 0x70 153376fbf20SRobert Jarzmik #define DOC_CMD_PLANES_STATUS 0x71 154efa2ca73SRobert Jarzmik 155efa2ca73SRobert Jarzmik #define DOC_CMD_RELIABLE_MODE 0x22 156efa2ca73SRobert Jarzmik #define DOC_CMD_FAST_MODE 0xa2 157efa2ca73SRobert Jarzmik 158efa2ca73SRobert Jarzmik #define DOC_CMD_RESET 0xff 159efa2ca73SRobert Jarzmik 160efa2ca73SRobert Jarzmik /* 161efa2ca73SRobert Jarzmik * Flash register : DOC_FLASHCONTROL 162efa2ca73SRobert Jarzmik */ 163efa2ca73SRobert Jarzmik #define DOC_CTRL_VIOLATION 0x20 164efa2ca73SRobert Jarzmik #define DOC_CTRL_CE 0x10 165efa2ca73SRobert Jarzmik #define DOC_CTRL_UNKNOWN_BITS 0x08 166efa2ca73SRobert Jarzmik #define DOC_CTRL_PROTECTION_ERROR 0x04 167efa2ca73SRobert Jarzmik #define DOC_CTRL_SEQUENCE_ERROR 0x02 168efa2ca73SRobert Jarzmik #define DOC_CTRL_FLASHREADY 0x01 169efa2ca73SRobert Jarzmik 170efa2ca73SRobert Jarzmik /* 171efa2ca73SRobert Jarzmik * Flash register : DOC_ASICMODE 172efa2ca73SRobert Jarzmik */ 173efa2ca73SRobert Jarzmik #define DOC_ASICMODE_RESET 0x00 174efa2ca73SRobert Jarzmik #define DOC_ASICMODE_NORMAL 0x01 175efa2ca73SRobert Jarzmik #define DOC_ASICMODE_POWERDOWN 0x02 176efa2ca73SRobert Jarzmik #define DOC_ASICMODE_MDWREN 0x04 177efa2ca73SRobert Jarzmik #define DOC_ASICMODE_BDETCT_RESET 0x08 178efa2ca73SRobert Jarzmik #define DOC_ASICMODE_RSTIN_RESET 0x10 179efa2ca73SRobert Jarzmik #define DOC_ASICMODE_RAM_WE 0x20 180efa2ca73SRobert Jarzmik 181efa2ca73SRobert Jarzmik /* 182efa2ca73SRobert Jarzmik * Flash register : DOC_ECCCONF0 183efa2ca73SRobert Jarzmik */ 184b604436cSRobert Jarzmik #define DOC_ECCCONF0_WRITE_MODE 0x0000 185efa2ca73SRobert Jarzmik #define DOC_ECCCONF0_READ_MODE 0x8000 186efa2ca73SRobert Jarzmik #define DOC_ECCCONF0_AUTO_ECC_ENABLE 0x4000 187efa2ca73SRobert Jarzmik #define DOC_ECCCONF0_HAMMING_ENABLE 0x1000 188efa2ca73SRobert Jarzmik #define DOC_ECCCONF0_BCH_ENABLE 0x0800 189efa2ca73SRobert Jarzmik #define DOC_ECCCONF0_DATA_BYTES_MASK 0x07ff 190efa2ca73SRobert Jarzmik 191efa2ca73SRobert Jarzmik /* 192efa2ca73SRobert Jarzmik * Flash register : DOC_ECCCONF1 193efa2ca73SRobert Jarzmik */ 194efa2ca73SRobert Jarzmik #define DOC_ECCCONF1_BCH_SYNDROM_ERR 0x80 195efa2ca73SRobert Jarzmik #define DOC_ECCCONF1_UNKOWN1 0x40 196376fbf20SRobert Jarzmik #define DOC_ECCCONF1_PAGE_IS_WRITTEN 0x20 197efa2ca73SRobert Jarzmik #define DOC_ECCCONF1_UNKOWN3 0x10 198efa2ca73SRobert Jarzmik #define DOC_ECCCONF1_HAMMING_BITS_MASK 0x0f 199efa2ca73SRobert Jarzmik 200efa2ca73SRobert Jarzmik /* 201efa2ca73SRobert Jarzmik * Flash register : DOC_PROTECTION 202efa2ca73SRobert Jarzmik */ 203efa2ca73SRobert Jarzmik #define DOC_PROTECT_FOUNDRY_OTP_LOCK 0x01 204efa2ca73SRobert Jarzmik #define DOC_PROTECT_CUSTOMER_OTP_LOCK 0x02 205efa2ca73SRobert Jarzmik #define DOC_PROTECT_LOCK_INPUT 0x04 206efa2ca73SRobert Jarzmik #define DOC_PROTECT_STICKY_LOCK 0x08 207efa2ca73SRobert Jarzmik #define DOC_PROTECT_PROTECTION_ENABLED 0x10 208efa2ca73SRobert Jarzmik #define DOC_PROTECT_IPL_DOWNLOAD_LOCK 0x20 209efa2ca73SRobert Jarzmik #define DOC_PROTECT_PROTECTION_ERROR 0x80 210efa2ca73SRobert Jarzmik 211efa2ca73SRobert Jarzmik /* 212efa2ca73SRobert Jarzmik * Flash register : DOC_DPS0_STATUS and DOC_DPS1_STATUS 213efa2ca73SRobert Jarzmik */ 214efa2ca73SRobert Jarzmik #define DOC_DPS_OTP_PROTECTED 0x01 215efa2ca73SRobert Jarzmik #define DOC_DPS_READ_PROTECTED 0x02 216efa2ca73SRobert Jarzmik #define DOC_DPS_WRITE_PROTECTED 0x04 217efa2ca73SRobert Jarzmik #define DOC_DPS_HW_LOCK_ENABLED 0x08 218efa2ca73SRobert Jarzmik #define DOC_DPS_KEY_OK 0x80 219efa2ca73SRobert Jarzmik 220efa2ca73SRobert Jarzmik /* 221efa2ca73SRobert Jarzmik * Flash register : DOC_CONFIGURATION 222efa2ca73SRobert Jarzmik */ 223efa2ca73SRobert Jarzmik #define DOC_CONF_IF_CFG 0x80 224efa2ca73SRobert Jarzmik #define DOC_CONF_MAX_ID_MASK 0x30 225efa2ca73SRobert Jarzmik #define DOC_CONF_VCCQ_3V 0x01 226efa2ca73SRobert Jarzmik 227efa2ca73SRobert Jarzmik /* 228efa2ca73SRobert Jarzmik * Flash register : DOC_READADDRESS 229efa2ca73SRobert Jarzmik */ 230efa2ca73SRobert Jarzmik #define DOC_READADDR_INC 0x8000 231efa2ca73SRobert Jarzmik #define DOC_READADDR_ONE_BYTE 0x4000 232efa2ca73SRobert Jarzmik #define DOC_READADDR_ADDR_MASK 0x1fff 233efa2ca73SRobert Jarzmik 234376fbf20SRobert Jarzmik /* 235e4b2a96aSRobert Jarzmik * Flash register : DOC_POWERMODE 236e4b2a96aSRobert Jarzmik */ 237e4b2a96aSRobert Jarzmik #define DOC_POWERDOWN_READY 0x80 238e4b2a96aSRobert Jarzmik 239e4b2a96aSRobert Jarzmik /* 240376fbf20SRobert Jarzmik * Status of erase and write operation 241376fbf20SRobert Jarzmik */ 242376fbf20SRobert Jarzmik #define DOC_PLANES_STATUS_FAIL 0x01 243376fbf20SRobert Jarzmik #define DOC_PLANES_STATUS_PLANE0_KO 0x02 244376fbf20SRobert Jarzmik #define DOC_PLANES_STATUS_PLANE1_KO 0x04 245376fbf20SRobert Jarzmik 2460f769d3fSRobert Jarzmik /* 2470f769d3fSRobert Jarzmik * DPS key management 2480f769d3fSRobert Jarzmik * 2490f769d3fSRobert Jarzmik * Each floor of docg3 has 2 protection areas: DPS0 and DPS1. These areas span 2500f769d3fSRobert Jarzmik * across block boundaries, and define whether these blocks can be read or 2510f769d3fSRobert Jarzmik * written. 2520f769d3fSRobert Jarzmik * The definition is dynamically stored in page 0 of blocks (2,3) for DPS0, and 2530f769d3fSRobert Jarzmik * page 0 of blocks (4,5) for DPS1. 2540f769d3fSRobert Jarzmik */ 2550f769d3fSRobert Jarzmik #define DOC_LAYOUT_DPS_KEY_LENGTH 8 2560f769d3fSRobert Jarzmik 257efa2ca73SRobert Jarzmik /** 2581b15a5f9SRobert Jarzmik * struct docg3_cascade - Cascade of 1 to 4 docg3 chips 2591b15a5f9SRobert Jarzmik * @floors: floors (ie. one physical docg3 chip is one floor) 2601b15a5f9SRobert Jarzmik * @base: IO space to access all chips in the cascade 2611b15a5f9SRobert Jarzmik * @bch: the BCH correcting control structure 2627b0e67f6SRobert Jarzmik * @lock: lock to protect docg3 IO space from concurrent accesses 2631b15a5f9SRobert Jarzmik */ 2641b15a5f9SRobert Jarzmik struct docg3_cascade { 2651b15a5f9SRobert Jarzmik struct mtd_info *floors[DOC_MAX_NBFLOORS]; 2661b15a5f9SRobert Jarzmik void __iomem *base; 2671b15a5f9SRobert Jarzmik struct bch_control *bch; 2687b0e67f6SRobert Jarzmik struct mutex lock; 2691b15a5f9SRobert Jarzmik }; 2701b15a5f9SRobert Jarzmik 2711b15a5f9SRobert Jarzmik /** 272efa2ca73SRobert Jarzmik * struct docg3 - DiskOnChip driver private data 273efa2ca73SRobert Jarzmik * @dev: the device currently under control 2741b15a5f9SRobert Jarzmik * @cascade: the cascade this device belongs to 275efa2ca73SRobert Jarzmik * @device_id: number of the cascaded DoCG3 device (0, 1, 2 or 3) 276efa2ca73SRobert Jarzmik * @if_cfg: if true, reads are on 16bits, else reads are on 8bits 277c3de8a8aSRobert Jarzmik 278c3de8a8aSRobert Jarzmik * @reliable: if 0, docg3 in normal mode, if 1 docg3 in fast mode, if 2 in 279c3de8a8aSRobert Jarzmik * reliable mode 280c3de8a8aSRobert Jarzmik * Fast mode implies more errors than normal mode. 281c3de8a8aSRobert Jarzmik * Reliable mode implies that page 2*n and 2*n+1 are clones. 282efa2ca73SRobert Jarzmik * @bbt: bad block table cache 283316e627eSRobert Jarzmik * @oob_write_ofs: offset of the MTD where this OOB should belong (ie. in next 284316e627eSRobert Jarzmik * page_write) 285316e627eSRobert Jarzmik * @oob_autoecc: if 1, use only bytes 0-7, 15, and fill the others with HW ECC 286316e627eSRobert Jarzmik * if 0, use all the 16 bytes. 287316e627eSRobert Jarzmik * @oob_write_buf: prepared OOB for next page_write 288efa2ca73SRobert Jarzmik */ 289efa2ca73SRobert Jarzmik struct docg3 { 290efa2ca73SRobert Jarzmik struct device *dev; 2911b15a5f9SRobert Jarzmik struct docg3_cascade *cascade; 292efa2ca73SRobert Jarzmik unsigned int device_id:4; 293efa2ca73SRobert Jarzmik unsigned int if_cfg:1; 294c3de8a8aSRobert Jarzmik unsigned int reliable:2; 295efa2ca73SRobert Jarzmik int max_block; 296efa2ca73SRobert Jarzmik u8 *bbt; 297316e627eSRobert Jarzmik loff_t oob_write_ofs; 298316e627eSRobert Jarzmik int oob_autoecc; 299316e627eSRobert Jarzmik u8 oob_write_buf[DOC_LAYOUT_OOB_SIZE]; 300efa2ca73SRobert Jarzmik }; 301efa2ca73SRobert Jarzmik 302efa2ca73SRobert Jarzmik #define doc_err(fmt, arg...) dev_err(docg3->dev, (fmt), ## arg) 303efa2ca73SRobert Jarzmik #define doc_info(fmt, arg...) dev_info(docg3->dev, (fmt), ## arg) 304efa2ca73SRobert Jarzmik #define doc_dbg(fmt, arg...) dev_dbg(docg3->dev, (fmt), ## arg) 305efa2ca73SRobert Jarzmik #define doc_vdbg(fmt, arg...) dev_vdbg(docg3->dev, (fmt), ## arg) 306efa2ca73SRobert Jarzmik #endif 307efa2ca73SRobert Jarzmik 308efa2ca73SRobert Jarzmik /* 309efa2ca73SRobert Jarzmik * Trace events part 310efa2ca73SRobert Jarzmik */ 311efa2ca73SRobert Jarzmik #undef TRACE_SYSTEM 312efa2ca73SRobert Jarzmik #define TRACE_SYSTEM docg3 313efa2ca73SRobert Jarzmik 314efa2ca73SRobert Jarzmik #if !defined(_MTD_DOCG3_TRACE) || defined(TRACE_HEADER_MULTI_READ) 315efa2ca73SRobert Jarzmik #define _MTD_DOCG3_TRACE 316efa2ca73SRobert Jarzmik 317efa2ca73SRobert Jarzmik #include <linux/tracepoint.h> 318efa2ca73SRobert Jarzmik 319efa2ca73SRobert Jarzmik TRACE_EVENT(docg3_io, 320efa2ca73SRobert Jarzmik TP_PROTO(int op, int width, u16 reg, int val), 321efa2ca73SRobert Jarzmik TP_ARGS(op, width, reg, val), 322efa2ca73SRobert Jarzmik TP_STRUCT__entry( 323efa2ca73SRobert Jarzmik __field(int, op) 324efa2ca73SRobert Jarzmik __field(unsigned char, width) 325efa2ca73SRobert Jarzmik __field(u16, reg) 326efa2ca73SRobert Jarzmik __field(int, val)), 327efa2ca73SRobert Jarzmik TP_fast_assign( 328efa2ca73SRobert Jarzmik __entry->op = op; 329efa2ca73SRobert Jarzmik __entry->width = width; 330efa2ca73SRobert Jarzmik __entry->reg = reg; 331efa2ca73SRobert Jarzmik __entry->val = val;), 332efa2ca73SRobert Jarzmik TP_printk("docg3: %s%02d reg=%04x, val=%04x", 333efa2ca73SRobert Jarzmik __entry->op ? "write" : "read", __entry->width, 334efa2ca73SRobert Jarzmik __entry->reg, __entry->val) 335efa2ca73SRobert Jarzmik ); 336efa2ca73SRobert Jarzmik #endif 337efa2ca73SRobert Jarzmik 338efa2ca73SRobert Jarzmik /* This part must be outside protection */ 339efa2ca73SRobert Jarzmik #undef TRACE_INCLUDE_PATH 340efa2ca73SRobert Jarzmik #undef TRACE_INCLUDE_FILE 341efa2ca73SRobert Jarzmik #define TRACE_INCLUDE_PATH . 342efa2ca73SRobert Jarzmik #define TRACE_INCLUDE_FILE docg3 343efa2ca73SRobert Jarzmik #include <trace/define_trace.h> 344