tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/flash/devices.go (about)

     1  package flash
     2  
     3  import "time"
     4  
     5  // A DeviceIdentifier can be passed to the Configure() method of a flash Device
     6  // in order provide a means of discovery of device-specific attributes based on
     7  // the JEDEC ID read from the device.
     8  type DeviceIdentifier interface {
     9  	// Identify returns an Attrs struct based on the provided JEDEC ID
    10  	Identify(id JedecID) Attrs
    11  }
    12  
    13  // DeviceIdentifierFunc is a functional Identifier implementation
    14  type DeviceIdentifierFunc func(id JedecID) Attrs
    15  
    16  // Identify implements the Identifier interface
    17  func (fn DeviceIdentifierFunc) Identify(id JedecID) Attrs {
    18  	return fn(id)
    19  }
    20  
    21  // DefaultDeviceIndentifier is a DeviceIdentifier that is capable of recognizing
    22  // JEDEC IDs for all of the known memory devices in this package. If you are
    23  // have no way to be sure about the type of memory device that might be on a
    24  // board you are targeting, this can be a good starting point to use.  The
    25  // downside of using this function is that it will prevent the compiler from
    26  // being able to mark any of the functions for the various devices as unused,
    27  // resulting in larger code size.  If code size is a concern, and if you know
    28  // ahead of time you are only dealing with a limited set of memory devices, it
    29  // might be worthwhile to use your own implementation of a DeviceIdentifier
    30  // that only references those devices, so that more methods are marked unused.
    31  var DefaultDeviceIdentifier = DeviceIdentifierFunc(func(id JedecID) Attrs {
    32  	switch id.Uint32() {
    33  	case 0x010617:
    34  		return S25FL064L()
    35  	case 0x014015:
    36  		return S25FL216K()
    37  	case 0x1F4501:
    38  		return AT25DF081A()
    39  	case 0xC22015:
    40  		return MX25L1606()
    41  	case 0xC22016:
    42  		return MX25L3233F()
    43  	case 0xC22817:
    44  		return MX25R6435F()
    45  	case 0xC84015:
    46  		return GD25Q16C()
    47  	case 0xC84017:
    48  		return GD25Q64C()
    49  	case 0xEF4015:
    50  		return W25Q16JVIQ()
    51  	case 0xEF4016:
    52  		return W25Q32FV()
    53  	case 0xEF4017:
    54  		return W25Q64JVIQ()
    55  	case 0xEF4018:
    56  		return W25Q128JVSQ()
    57  	case 0xEF6014:
    58  		return W25Q80DL()
    59  	case 0xEF6015:
    60  		return W25Q16FW()
    61  	case 0xEF6016:
    62  		return W25Q32BV()
    63  	case 0xEF7015:
    64  		return W25Q16JVIM()
    65  	case 0xEF7016:
    66  		return W25Q32JVIM()
    67  	case 0xEF7017:
    68  		return W25Q64JVIM()
    69  	case 0xEF7018:
    70  		return W25Q128JVPM()
    71  	default:
    72  		return Attrs{JedecID: id}
    73  	}
    74  })
    75  
    76  // Settings for the Cypress (was Spansion) S25FL064L 8MiB SPI flash.
    77  // Datasheet: http://www.cypress.com/file/316661/download
    78  func S25FL064L() Attrs {
    79  	return Attrs{
    80  		TotalSize:           1 << 23, // 8 MiB
    81  		StartUp:             300 * time.Microsecond,
    82  		JedecID:             JedecID{0x01, 0x60, 0x17},
    83  		MaxClockSpeedMHz:    108,
    84  		QuadEnableBitMask:   0x02,
    85  		HasSectorProtection: false,
    86  		SupportsFastRead:    true,
    87  		SupportsQSPI:        true,
    88  		SupportsQSPIWrites:  true,
    89  		WriteStatusSplit:    false,
    90  		SingleStatusByte:    false,
    91  	}
    92  }
    93  
    94  // Settings for the Cypress (was Spansion) S25FL116K 2MiB SPI flash.
    95  // Datasheet: http://www.cypress.com/file/196886/download
    96  func S25FL116K() Attrs {
    97  	return Attrs{
    98  		TotalSize:           1 << 21, // 2 MiB
    99  		StartUp:             10000 * time.Microsecond,
   100  		JedecID:             JedecID{0x01, 0x40, 0x15},
   101  		MaxClockSpeedMHz:    108,
   102  		QuadEnableBitMask:   0x02,
   103  		HasSectorProtection: false,
   104  		SupportsFastRead:    true,
   105  		SupportsQSPI:        true,
   106  		SupportsQSPIWrites:  false,
   107  		WriteStatusSplit:    false,
   108  		SingleStatusByte:    false,
   109  	}
   110  }
   111  
   112  // Settings for the Cypress (was Spansion) S25FL216K 2MiB SPI flash.
   113  // Datasheet: http://www.cypress.com/file/197346/download
   114  func S25FL216K() Attrs {
   115  	return Attrs{
   116  		TotalSize:           1 << 21, // 2 MiB
   117  		StartUp:             10000 * time.Microsecond,
   118  		JedecID:             JedecID{0x01, 0x40, 0x15},
   119  		MaxClockSpeedMHz:    65,
   120  		QuadEnableBitMask:   0x02,
   121  		HasSectorProtection: false,
   122  		SupportsFastRead:    true,
   123  		SupportsQSPI:        true,
   124  		SupportsQSPIWrites:  false,
   125  		WriteStatusSplit:    false,
   126  		SingleStatusByte:    false,
   127  	}
   128  }
   129  
   130  // Settings for the Adesto Tech AT25DF081A 1MiB SPI flash. Its on the SAMD21
   131  // Xplained board.
   132  // Datasheet: https://www.adestotech.com/wp-content/uploads/doc8715.pdf
   133  func AT25DF081A() Attrs {
   134  	return Attrs{
   135  		TotalSize:           1 << 20, // 1 MiB
   136  		StartUp:             10000 * time.Microsecond,
   137  		JedecID:             JedecID{0x1F, 0x45, 0x01},
   138  		MaxClockSpeedMHz:    85,
   139  		QuadEnableBitMask:   0x00,
   140  		HasSectorProtection: true,
   141  		SupportsFastRead:    true,
   142  		SupportsQSPI:        false,
   143  		SupportsQSPIWrites:  false,
   144  		WriteStatusSplit:    false,
   145  		SingleStatusByte:    false,
   146  	}
   147  }
   148  
   149  // Settings for the Macronix MX25L1606 2MiB SPI flash.
   150  // Datasheet:
   151  func MX25L1606() Attrs {
   152  	return Attrs{
   153  		TotalSize:           1 << 21, // 2 MiB,
   154  		StartUp:             5000 * time.Microsecond,
   155  		JedecID:             JedecID{0xC2, 0x20, 0x15},
   156  		MaxClockSpeedMHz:    8,
   157  		QuadEnableBitMask:   0x40,
   158  		HasSectorProtection: false,
   159  		SupportsFastRead:    true,
   160  		SupportsQSPI:        true,
   161  		SupportsQSPIWrites:  true,
   162  		WriteStatusSplit:    false,
   163  		SingleStatusByte:    true,
   164  	}
   165  }
   166  
   167  // Settings for the Macronix MX25L3233F 4MiB SPI flash.
   168  // Datasheet:
   169  // http://www.macronix.com/Lists/Datasheet/Attachments/7426/MX25L3233F,%203V,%2032Mb,%20v1.6.pdf
   170  func MX25L3233F() Attrs {
   171  	return Attrs{
   172  		TotalSize:           1 << 22, // 4 MiB
   173  		StartUp:             5000 * time.Microsecond,
   174  		JedecID:             JedecID{0xC2, 0x20, 0x16},
   175  		MaxClockSpeedMHz:    133,
   176  		QuadEnableBitMask:   0x40,
   177  		HasSectorProtection: false,
   178  		SupportsFastRead:    true,
   179  		SupportsQSPI:        true,
   180  		SupportsQSPIWrites:  true,
   181  		WriteStatusSplit:    false,
   182  		SingleStatusByte:    false,
   183  	}
   184  }
   185  
   186  // Settings for the Macronix MX25R6435F 8MiB SPI flash.
   187  // Datasheet:
   188  // http://www.macronix.com/Lists/Datasheet/Attachments/7428/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.4.pdf
   189  // By default its in lower power mode which can only do 8mhz. In high power mode
   190  // it can do 80mhz.
   191  func MX25R6435F() Attrs {
   192  	return Attrs{
   193  		TotalSize:           1 << 23, // 8 MiB
   194  		StartUp:             5000 * time.Microsecond,
   195  		JedecID:             JedecID{0xC2, 0x28, 0x17},
   196  		MaxClockSpeedMHz:    8,
   197  		QuadEnableBitMask:   0x40,
   198  		HasSectorProtection: false,
   199  		SupportsFastRead:    true,
   200  		SupportsQSPI:        true,
   201  		SupportsQSPIWrites:  true,
   202  		WriteStatusSplit:    false,
   203  		SingleStatusByte:    true,
   204  	}
   205  }
   206  
   207  // Settings for the Gigadevice GD25Q16C 2MiB SPI flash.
   208  // Datasheet: http://www.gigadevice.com/datasheet/gd25q16c/
   209  func GD25Q16C() Attrs {
   210  	return Attrs{
   211  		TotalSize:          1 << 21, // 2 MiB
   212  		StartUp:            5000 * time.Microsecond,
   213  		JedecID:            JedecID{0xC8, 0x40, 0x15},
   214  		MaxClockSpeedMHz:   104,
   215  		QuadEnableBitMask:  0x02,
   216  		SupportsFastRead:   true,
   217  		SupportsQSPI:       true,
   218  		SupportsQSPIWrites: true,
   219  		WriteStatusSplit:   false,
   220  		SingleStatusByte:   false,
   221  	}
   222  }
   223  
   224  // Settings for the Gigadevice GD25Q64C 8MiB SPI flash.
   225  // Datasheet: http://www.elm-tech.com/en/products/spi-flash-memory/gd25q64/gd25q64.pdf
   226  func GD25Q64C() Attrs {
   227  	return Attrs{
   228  		TotalSize:           1 << 23, // 8 MiB
   229  		StartUp:             5000 * time.Microsecond,
   230  		JedecID:             JedecID{0xC8, 0x40, 0x17},
   231  		MaxClockSpeedMHz:    104,
   232  		QuadEnableBitMask:   0x02,
   233  		HasSectorProtection: false,
   234  		SupportsFastRead:    true,
   235  		SupportsQSPI:        true,
   236  		SupportsQSPIWrites:  true,
   237  		WriteStatusSplit:    true,
   238  		SingleStatusByte:    false,
   239  	}
   240  }
   241  
   242  // Settings for the Winbond W25Q16JV-IQ 2MiB SPI flash. Note that JV-IM has a
   243  // different .memory_type (0x70) Datasheet:
   244  // https://www.winbond.com/resource-files/w25q16jv%20spi%20revf%2005092017.pdf
   245  func W25Q16JVIQ() Attrs {
   246  	return Attrs{
   247  		TotalSize:           1 << 21, // 2 MiB
   248  		StartUp:             5000 * time.Microsecond,
   249  		JedecID:             JedecID{0xEF, 0x40, 0x15},
   250  		MaxClockSpeedMHz:    133,
   251  		QuadEnableBitMask:   0x02,
   252  		HasSectorProtection: false,
   253  		SupportsFastRead:    true,
   254  		SupportsQSPI:        true,
   255  		SupportsQSPIWrites:  true,
   256  		WriteStatusSplit:    false,
   257  		SingleStatusByte:    false,
   258  	}
   259  }
   260  
   261  // Settings for the Winbond W25Q16FW 2MiB SPI flash.
   262  // Datasheet:
   263  // https://www.winbond.com/resource-files/w25q16fw%20revj%2005182017%20sfdp.pdf
   264  func W25Q16FW() Attrs {
   265  	return Attrs{
   266  		TotalSize:           1 << 21, // 2 MiB
   267  		StartUp:             5000 * time.Microsecond,
   268  		JedecID:             JedecID{0xEF, 0x60, 0x15},
   269  		MaxClockSpeedMHz:    133,
   270  		QuadEnableBitMask:   0x02,
   271  		HasSectorProtection: false,
   272  		SupportsFastRead:    true,
   273  		SupportsQSPI:        true,
   274  		SupportsQSPIWrites:  true,
   275  		WriteStatusSplit:    false,
   276  		SingleStatusByte:    false,
   277  	}
   278  }
   279  
   280  // Settings for the Winbond W25Q16JV-IM 2MiB SPI flash. Note that JV-IQ has a
   281  // different .memory_type (0x40) Datasheet:
   282  // https://www.winbond.com/resource-files/w25q16jv%20spi%20revf%2005092017.pdf
   283  func W25Q16JVIM() Attrs {
   284  	return Attrs{
   285  		TotalSize:           1 << 21, // 2 MiB
   286  		StartUp:             5000 * time.Microsecond,
   287  		JedecID:             JedecID{0xEF, 0x70, 0x15},
   288  		MaxClockSpeedMHz:    133,
   289  		QuadEnableBitMask:   0x02,
   290  		HasSectorProtection: false,
   291  		SupportsFastRead:    true,
   292  		SupportsQSPI:        true,
   293  		SupportsQSPIWrites:  true,
   294  		WriteStatusSplit:    false,
   295  		SingleStatusByte:    false,
   296  	}
   297  }
   298  
   299  // Settings for the Winbond W25Q32BV 4MiB SPI flash.
   300  // Datasheet:
   301  // https://www.winbond.com/resource-files/w25q32bv_revi_100413_wo_automotive.pdf
   302  func W25Q32BV() Attrs {
   303  	return Attrs{
   304  		TotalSize:           1 << 22, // 4 MiB
   305  		StartUp:             10000 * time.Microsecond,
   306  		JedecID:             JedecID{0xEF, 0x60, 0x16},
   307  		MaxClockSpeedMHz:    104,
   308  		QuadEnableBitMask:   0x02,
   309  		HasSectorProtection: false,
   310  		SupportsFastRead:    true,
   311  		SupportsQSPI:        true,
   312  		SupportsQSPIWrites:  false,
   313  		WriteStatusSplit:    false,
   314  		SingleStatusByte:    false,
   315  	}
   316  }
   317  
   318  // Settings for the Winbond W25Q32JV-IM 4MiB SPI flash.
   319  // Datasheet:
   320  // https://www.winbond.com/resource-files/w25q32jv%20revg%2003272018%20plus.pdf
   321  func W25Q32JVIM() Attrs {
   322  	return Attrs{
   323  		TotalSize:           1 << 22, // 4 MiB
   324  		StartUp:             5000 * time.Microsecond,
   325  		JedecID:             JedecID{0xEF, 0x70, 0x16},
   326  		MaxClockSpeedMHz:    133,
   327  		QuadEnableBitMask:   0x02,
   328  		HasSectorProtection: false,
   329  		SupportsFastRead:    true,
   330  		SupportsQSPI:        true,
   331  		SupportsQSPIWrites:  true,
   332  		WriteStatusSplit:    false,
   333  		SingleStatusByte:    false,
   334  	}
   335  }
   336  
   337  // Settings for the Winbond W25Q64JV-IM 8MiB SPI flash. Note that JV-IQ has a
   338  // different .memory_type (0x40) Datasheet:
   339  // http://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf
   340  func W25Q64JVIM() Attrs {
   341  	return Attrs{
   342  		TotalSize:           1 << 23, // 8 MiB
   343  		StartUp:             5000 * time.Microsecond,
   344  		JedecID:             JedecID{0xEF, 0x70, 0x17},
   345  		MaxClockSpeedMHz:    133,
   346  		QuadEnableBitMask:   0x02,
   347  		HasSectorProtection: false,
   348  		SupportsFastRead:    true,
   349  		SupportsQSPI:        true,
   350  		SupportsQSPIWrites:  true,
   351  		WriteStatusSplit:    false,
   352  		SingleStatusByte:    false,
   353  	}
   354  }
   355  
   356  // Settings for the Winbond W25Q64JV-IQ 8MiB SPI flash. Note that JV-IM has a
   357  // different .memory_type (0x70) Datasheet:
   358  // http://www.winbond.com/resource-files/w25q64jv%20revj%2003272018%20plus.pdf
   359  func W25Q64JVIQ() Attrs {
   360  	return Attrs{
   361  		TotalSize:           1 << 23, // 8 MiB
   362  		StartUp:             5000 * time.Microsecond,
   363  		JedecID:             JedecID{0xEF, 0x40, 0x17},
   364  		MaxClockSpeedMHz:    133,
   365  		QuadEnableBitMask:   0x02,
   366  		HasSectorProtection: false,
   367  		SupportsFastRead:    true,
   368  		SupportsQSPI:        true,
   369  		SupportsQSPIWrites:  true,
   370  		WriteStatusSplit:    false,
   371  		SingleStatusByte:    false,
   372  	}
   373  }
   374  
   375  // Settings for the Winbond W25Q80DL 1MiB SPI flash.
   376  // Datasheet:
   377  // https://www.winbond.com/resource-files/w25q80dv%20dl_revh_10022015.pdf
   378  func W25Q80DL() Attrs {
   379  	return Attrs{
   380  		TotalSize:           1 << 20, // 1 MiB
   381  		StartUp:             5000 * time.Microsecond,
   382  		JedecID:             JedecID{0xEF, 0x60, 0x14},
   383  		MaxClockSpeedMHz:    104,
   384  		QuadEnableBitMask:   0x02,
   385  		HasSectorProtection: false,
   386  		SupportsFastRead:    true,
   387  		SupportsQSPI:        true,
   388  		SupportsQSPIWrites:  false,
   389  		WriteStatusSplit:    false,
   390  		SingleStatusByte:    false,
   391  	}
   392  }
   393  
   394  // Settings for the Winbond W25Q128JV-SQ 16MiB SPI flash. Note that JV-IM has a
   395  // different .memory_type (0x70) Datasheet:
   396  // https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf
   397  func W25Q128JVSQ() Attrs {
   398  	return Attrs{
   399  		TotalSize:           1 << 24, // 16 MiB
   400  		StartUp:             5000 * time.Microsecond,
   401  		JedecID:             JedecID{0xEF, 0x40, 0x18},
   402  		MaxClockSpeedMHz:    133,
   403  		QuadEnableBitMask:   0x02,
   404  		HasSectorProtection: false,
   405  		SupportsFastRead:    true,
   406  		SupportsQSPI:        true,
   407  		SupportsQSPIWrites:  true,
   408  		WriteStatusSplit:    false,
   409  		SingleStatusByte:    false,
   410  	}
   411  }
   412  
   413  // Settings for the Winbond W25Q128JV-PM 16MiB SPI flash. Note that JV-IM has a
   414  // different .memory_type (0x70) Datasheet:
   415  // https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf
   416  func W25Q128JVPM() Attrs {
   417  	return Attrs{
   418  		TotalSize:           1 << 24, // 16 MiB
   419  		StartUp:             5000 * time.Microsecond,
   420  		JedecID:             JedecID{0xEF, 0x70, 0x18},
   421  		MaxClockSpeedMHz:    133,
   422  		QuadEnableBitMask:   0x02,
   423  		HasSectorProtection: false,
   424  		SupportsFastRead:    true,
   425  		SupportsQSPI:        true,
   426  		SupportsQSPIWrites:  true,
   427  		WriteStatusSplit:    false,
   428  		SingleStatusByte:    false,
   429  	}
   430  }
   431  
   432  // Settings for the Winbond W25Q32FV 4MiB SPI flash.
   433  // Datasheet:http://www.winbond.com/resource-files/w25q32fv%20revj%2006032016.pdf?__locale=en
   434  func W25Q32FV() Attrs {
   435  	return Attrs{
   436  		TotalSize:           1 << 22, // 4 MiB
   437  		StartUp:             5000 * time.Microsecond,
   438  		JedecID:             JedecID{0xEF, 0x40, 0x16},
   439  		MaxClockSpeedMHz:    104,
   440  		QuadEnableBitMask:   0x00,
   441  		HasSectorProtection: false,
   442  		SupportsFastRead:    true,
   443  		SupportsQSPI:        false,
   444  		SupportsQSPIWrites:  false,
   445  		WriteStatusSplit:    false,
   446  		SingleStatusByte:    false,
   447  	}
   448  }