xref: /openbmc/u-boot/board/gdsys/p1022/ddr.c (revision ea743e65)
1 /*
2  * Copyright 2010 Freescale Semiconductor, Inc.
3  * Authors: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
4  *          Timur Tabi <timur@freescale.com>
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #include <common.h>
10 #include <i2c.h>
11 
12 #include <fsl_ddr_sdram.h>
13 #include <fsl_ddr_dimm_params.h>
14 
15 void fsl_ddr_board_options(memctl_options_t *popts, dimm_params_t *pdimm,
16 			   unsigned int ctrl_num)
17 {
18 	unsigned int i;
19 
20 	if (ctrl_num) {
21 		printf("Wrong parameter for controller number %d", ctrl_num);
22 		return;
23 	}
24 	if (!pdimm->n_ranks)
25 		return;
26 
27 	/* set odt_rd_cfg and odt_wr_cfg. */
28 	for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) {
29 		popts->cs_local_opts[i].odt_rd_cfg = 0;
30 		popts->cs_local_opts[i].odt_wr_cfg = 1;
31 	}
32 
33 	popts->clk_adjust = 5;
34 	popts->cpo_override = 0x1f;
35 	popts->write_data_delay = 2;
36 	popts->half_strength_driver_enable = 1;
37 
38 	/* Per AN4039, enable ZQ calibration. */
39 	popts->zq_en = 1;
40 }
41 
42 #ifdef CONFIG_SPD_EEPROM
43 /*
44  * we only have a "fake" SPD-EEPROM here, which has 16 bit addresses
45  */
46 void get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
47 {
48 	int ret = i2c_read(i2c_address, 0, 2, (uchar *)spd,
49 				sizeof(generic_spd_eeprom_t));
50 
51 	if (ret) {
52 		if (i2c_address ==
53 #ifdef SPD_EEPROM_ADDRESS
54 				SPD_EEPROM_ADDRESS
55 #elif defined(SPD_EEPROM_ADDRESS1)
56 				SPD_EEPROM_ADDRESS1
57 #endif
58 				) {
59 			printf("DDR: failed to read SPD from address %u\n",
60 			       i2c_address);
61 		} else {
62 			debug("DDR: failed to read SPD from address %u\n",
63 			      i2c_address);
64 		}
65 		memset(spd, 0, sizeof(generic_spd_eeprom_t));
66 	}
67 }
68 #endif
69