Commit Graph

7523 Commits

Author SHA1 Message Date
Marek Vasut
9c76df518c ddr: altera: sequencer: Move qts-generated files to board dir
Move the files generated by QTS into the board directory, they should not
be part of the driver files at all.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Dinh Nguyen <dinguyen@opensource.altera.com>
2015-08-08 14:14:28 +02:00
Marek Vasut
08eb947004 ddr: altera: sdram: Make sdram_start and sdram_end into u32
Originally, both sdram_start and sdram_end were 64b values. The
sdram_start had no reason for being so, since our address space
is only 32b, so switching sdram_start to u32 is simple.

The sdram_end is a bit more complex, since it can actually be
set to (1 << 32) if someone really wanted to use an SoCFPGA with
4 GiB of DRAM and fixed the code around a little. But, the code
handling the protection rules internally decrements the sdram_end
variable anyway. Thus, instead of calling the code and passing in
the address of the SDRAM end, pass in the address already decremented
by one. This lets the sdram_end be 32b as well.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:28 +02:00
Marek Vasut
6d01595f63 ddr: altera: sdram: Minor cleanup in sdram_get_rule()
Fix the data types and zap unnecessary type change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:28 +02:00
Marek Vasut
a003740aec ddr: altera: sdram: Minor cleanup in sdram_set_rule()
Zap an obscure unneeded cast and clean other minor nits in this function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:28 +02:00
Marek Vasut
96b869b6e3 ddr: altera: sdram: Add missing kerneldoc
Add kerneldoc to functions which are missing it, but are already
cleaned up.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:28 +02:00
Marek Vasut
269de4f0ab ddr: altera: sdram: Clean up sdram_write_verify()
Clean the function up so that it's obvious what it is doing,
fix the formating strings in debug outputs, add kerneldoc.
Make the function return proper errno-compliant return values
and propagate this change throughout sdram.c

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:28 +02:00
Marek Vasut
f97606f237 ddr: altera: sdram: Clean up sdram_calculate_size() part 2
Clean up coding style, mostly clean up comments, add kerneldoc.
Also, zap assignment of the "cs" variable, which is outright
dead code, so just remove it.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
bb056d9c07 ddr: altera: sdram: Clean up sdram_calculate_size() part 1
Pluck out all of the CONFIG_HPS_SDR_CTRLCFG_* macros. This change
makes sdram.c completely clear of these macros and allows removing
of the ugly include of sdram.h . The namespace is now a much nicer
place!

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
5af914189e ddr: altera: sdram: Introduce socfpga_sdram_get_config()
Introduce socfpga_sdram_get_config() function implement in a board file,
which returns the socfpga_sdram_config structure. This is the last step
in cleaning up the socfpga_mmr_init_full(), but not the last step which
allows removing the inclusion of sdram.h from drivers/ddr/altera/sdram.c
thus far.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
99f453e953 ddr: altera: sdram: Clean up sdram_mmr_init_full() part 8
Fix the return value so that standard errno return values can be used.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
1e8a85f8c5 ddr: altera: sdram: Clean up sdram_mmr_init_full() part 7
Add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
1a302a4525 ddr: altera: sdram: Clean up sdram_mmr_init_full() part 6
Pull out the block of register programming into a separate function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
9d6b012c72 ddr: altera: sdram: Clean up sdram_mmr_init_full() part 5
Rework remaining two register setting functions such that they only
return the final register value. Move the register setting into the
block of register I/O in sdram_mmr_init_full().

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
076470eecd ddr: altera: sdram: Clean up sdram_mmr_init_full() part 4
Merge sdr_set_*() functions which are just setting registers among
the sea of register setting in sdram_mmr_init_full(). There is no
need to keep them separate this way, there is nothing special about
them.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
764aa9a974 ddr: altera: sdram: Clean up sdram_mmr_init_full() part 3
Pluck out the remaining CONFIG_HPS_SDR_CTRLCFG_ and put it into
the socfpga_sdram_config structure.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:27 +02:00
Marek Vasut
dc3b91d9b6 ddr: altera: sdram: Clean up sdram_mmr_init_full() part 2
Suck out all the CONFIG_HPS_SDR_CTRLCFG_* from sdram_mmr_init_full()
into the socfpga_sdram_config structure. There is still one ugly
macro left behind, but this will be taken care of in subsequent patch.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
be9a9fc5e6 ddr: altera: sdram: Clean up sdram_mmr_init_full() part 1
Zap all the ad-hoc readbacks from the registers and other useless
and broken debug output. This is really not useful and is only
confusing.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
04ae448997 ddr: altera: sdram: Introduce socfpga_sdram_config() structure
Introduce this seemingly massive structure, which holds required values
of all the registers of the SDRAM controller. The idea here is to avoid
including the sdram.h header file, which is full of ad-hoc macros that
polute the global namespace. Once the cleanup of sdram.c would be complete
and all registers would be loaded from this new socfpga_sdram_config, a
board file will only pass this structure into the sdram.c . This will
hide all the horrors generated by QTS in the board directory.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
9a48a9ac6c ddr: altera: sdram: Clean up set_sdr_mp_threshold()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
ad2ba5d607 ddr: altera: sdram: Clean up set_sdr_mp_pacing()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
a5ba929671 ddr: altera: sdram: Clean up set_sdr_mp_weight()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
1009e396dd ddr: altera: sdram: Clean up set_sdr_fifo_cfg()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
b3bdb2204e ddr: altera: sdram: Clean up set_sdr_static_cfg()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
0ef8830037 ddr: altera: sdram: Clean up set_sdr_addr_rw()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
60bd0df018 ddr: altera: sdram: Clean up set_sdr_dram_timing*()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.
Merge set_sdr_dram_timing{1,2,3,4,lowpwr}() into single function
set_sdr_dram_timing() , since there's no point in keeping all this
stuff separate anymore.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:26 +02:00
Marek Vasut
067c853fe6 ddr: altera: sdram: Clean up set_sdr_ctrlcfg()
Get rid of the constant clrsetbits_le32(), instead prepare the whole
content of the register once and write it at the end of the function.
The big plan here is to remove all the CONFIG_HPS_SDR_ macros, hide
them in QTS compatibility layer in board implementation and pass only
a small structure into the driver.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:25 +02:00
Marek Vasut
f36716971d ddr: altera: sdram: Clean up compute_errata_rows() part 2
Remove all parameters of this function, since they are only constants
passed in from another function, so make them local. Also, rename the
function to get_errata_rows() as this is closer to what it does.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:25 +02:00
Marek Vasut
791d20e13d ddr: altera: sdram: Clean up compute_errata_rows() part 1
Clean up weird parenthesis and odd type casts from the function.
Fix comment style.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:25 +02:00
Marek Vasut
58d86144d4 ddr: altera: sdram: Switch to generic_hweight32()
Use generic function instead of CPU-specific one.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:25 +02:00
Marek Vasut
3de9622e97 ddr: altera: Clean up of delay_for_n_mem_clocks() part 5
Add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:24 +02:00
Marek Vasut
0c1b81bdf3 ddr: altera: Clean up of delay_for_n_mem_clocks() part 4
Simplify the loop code, optimizing compiler can deal with this.
No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:24 +02:00
Marek Vasut
6a39be6ca9 ddr: altera: Clean up of delay_for_n_mem_clocks() part 3
Clean up the computation of c_loop, outer and inner variables.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:24 +02:00
Marek Vasut
cbcaf46043 ddr: altera: Clean up of delay_for_n_mem_clocks() part 2
Factor out (afi_clocks - 1) into a single place instead of having it
all around the function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:24 +02:00
Marek Vasut
90a584b763 ddr: altera: Clean up of delay_for_n_mem_clocks() part 1
Fix data types, clean up comments a bit and fix coding style a bit.
No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:24 +02:00
Marek Vasut
f1f22f7204 ddr: altera: Minor clean up of rw_mgr_mem_handoff()
Add kerneldoc and perform a minor comment cleanup.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:24 +02:00
Marek Vasut
c984278a66 ddr: altera: Clean up rw_mgr_mem_calibrate_lfifo()
Minor coding style cleanup, add kerneldoc. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
78cdd7d0c8 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_end()
This function is implementing the DDR calibration Stage 3 as
described in Altera EMI_RM 2015.05.04 . The main body of this
function is almost identical to Stage 1.3 (DQ/DQS centering)
for all but two flags -- use_read_test and update_fom. Convert
this function to call rw_mgr_mem_calibrate_dq_dqs_centering()
with the correct flags set to trim down the code duplication.

Moreover, reorder the remnants in the function a little and
convert the function to return either 0 or -EIO in case of
success and failure respectively, to match the common return
value convention.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
8371c2ee68 ddr: altera: Clean up rw_mgr_mem_calibrate_write_test_issue()
Brief clean, add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
4a82854b07 ddr: altera: Clean up rw_mgr_mem_calibrate_write_test() part 3
Add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
b9452ea09f ddr: altera: Clean up rw_mgr_mem_calibrate_write_test() part 2
Clean up coding style, mostly broken multiline formatting strings
in debug output. Also clean up data types and constify where applicable.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
ad64769ce0 ddr: altera: Clean up rw_mgr_mem_calibrate_write_test() part 1
Move code around to get rid of the forward declaration. No change
to the actual code.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
a386a50eb2 ddr: altera: Clean up rw_mgr_mem_calibrate_writes_center() part 5
Add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
d043ee5b49 ddr: altera: Clean up rw_mgr_mem_calibrate_writes_center() part 4
Fix return values to match the common return value convention.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
c654087206 ddr: altera: Clean up rw_mgr_mem_calibrate_writes_center() part 3
Zap the useless addr variable.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:23 +02:00
Marek Vasut
c8570afa04 ddr: altera: Clean up rw_mgr_mem_calibrate_writes_center() part 2
Factor out common code for searching best DM/DQS window.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
3b44f55c3b ddr: altera: Clean up rw_mgr_mem_calibrate_writes_center() part 1
Fix data types and constify where applicable, fix broken multiline
debug strings and fix comments. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
ac63b9ada5 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 11
Add kerneldoc, no functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
9866824794 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 10
Fix the return value of the function to match common convention
where 0 means success and negative means error. Fix the return
values in case of an error to use errno.h codes.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
0113c3e1fe ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 9
The read_group and write_group arguments are the same in all
cases when this function is invoked, just merge them into one
rw_group argument. Also, clean up the function argument data
types and constify them.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
0c4be198f4 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 8
The search_stop_check() always resets the bit_chk to a new value,
so bit_chk will never survive between search_left_edge() and
search_right_edge() invocation. There is thus no need to pass
it into these functions, so make bit_chk local to them.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
5d6db44485 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 7
Perform minor reordering of the function to make the code more
organised, no functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
ffb8b66ea8 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 6
Factor out center_dq_windows(), which is common code between
stage 2 and stage 3 of the calibration again and cater for
the minor differences.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
afb3eb84b8 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 5
Factor out the get_window_mid_index() for finding the best DQ
window centering. This is again code common to two stages, so
pull it out.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:22 +02:00
Marek Vasut
f0712c3502 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 4
First of all, don't break strings in the debug_cond() calls across
multiple lines. Next, zap a couple of really odd casts in the code.
Finally, make i into a signed variable, so it is possible to avoid
constructs of the form:
    for (i = FOO;; i--) { <code>; if (i == 0) break; }.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
901dc36e7a ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 3
Factor out common code from search_left_edge() and search_right_edge()
which checks whether searching for the window edge should stop. The
code is almost identical, so pull it into separate function and cater
for the minor differences.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
71120773bf ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 2
Factor out common code from rw_mgr_mem_calibrate_writes_center()
and rw_mgr_mem_calibrate_vfifo_center() for searching for the
left edge of the window. The code is almost identical, so pull
it into separate function and cater for the minor differences.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
c4907898a1 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_center() part 1
Factor out common code from rw_mgr_mem_calibrate_writes_center()
and rw_mgr_mem_calibrate_vfifo_center() for searching for the
right edge of the window. The code is almost identical, so pull
it into separate function and cater for the minor differences.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
db3a606158 ddr: altera: Clean up rw_mgr_mem_calibrate_writes()
Reorder the content of the function a little and fix the comments
so they at least become full sentences. Constify function args.
Fix the return value to match the common convention of 0 meaning
success.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
783fcf59bd ddr: altera: Clean up rw_mgr_mem_calibrate_read_test() part 5
Make the function documentation into kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
ba522c769e ddr: altera: Clean up rw_mgr_mem_calibrate_read_test() part 4
Clean up the inner loop a bit. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
7ce23bb6ef ddr: altera: Clean up rw_mgr_mem_calibrate_read_test() part 3
The C language has signed types, so make use of them. Fix this
obscene loop, which tries to do away with unsigned type, but
just makes the code more cryptic.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
3cb8bf3fc5 ddr: altera: Clean up rw_mgr_mem_calibrate_read_test() part 2
Clean up data types and constify where applicable. No function change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
3853d65e20 ddr: altera: Clean up rw_mgr_mem_calibrate_read_test() part 1
Clean up the debug output handling at the end of the function
and factor out common function call from the condition.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:21 +02:00
Marek Vasut
96df60364d ddr: altera: Clean up rw_mgr_mem_calibrate_read_test_all_ranks()
Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
33756893ad ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 7
Add kerneldoc, no functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
914546e7f0 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 6
Fix the return value to match common conventions and propagate
this change through the code.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
5735540fd9 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 5
Fix the data types, constify where applicable.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
52e8f217f9 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 4
Implement common sdr_find_phase_delay() function and convert all
places which use such code to this unified function. No functional
change to the code.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
37b7b13d48 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 3
Clean up odd multiline loop, no functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
23e8ea901a ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 2
If d != 0 after sdr_working_phase() finishes, the else branch
of the condition has no impact on anything at all, since work_end
was already set independently of the value of "d" . Zap this
useless code.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
2f3589ca54 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 1
Fix broken multiline debug strings, fix comments.
No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
d145ca9fc3 ddr: altera: Clean up find_vfifo_read()
Fix data types, constify where applicable, fix comments and debug
strings. In case enough failing reads are detected, just return
right away instead of breaking from the loop. This lets us make
the error handling at the end much simpler.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:20 +02:00
Marek Vasut
8c887b6ec3 ddr: altera: Clean up rw_mgr_*_vfifo() part 2
Pluck out all this VFIFO value counting, which turns out to be
completely unused. Thus, remove it to simplify the code.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
60bb8a8a7e ddr: altera: Clean up rw_mgr_*_vfifo() part 1
Perform minor cleanup, fix data types and constify where applicable.
Add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
4c5e584b2d ddr: altera: Clean up sdr_*_phase() part 10
Clean up data types, constify where applicable and document the
functions with kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
49891df661 ddr: altera: Clean up sdr_*_phase() part 9
The "d" variable is set to 0 in sdr_backup_phase() and is not used
at all in sdr_nonworking_phase(). Make it local and zap it respectively.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
a80f45346e ddr: altera: Clean up sdr_*_phase() part 8
The work_bgn parameter of sdr_nonworking_phase() is unused, zap it.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
35ee867fc2 ddr: altera: Clean up sdr_*_phase() part 7
Wrap dtaps_per_ptap into the sdr_working_phase() function to trim
down the number of params. It's a constant too.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
86a39dc76e ddr: altera: Clean up sdr_*_phase() part 6
It is now clear that the max_working_cnt variable is totally unused.
Zap the variable and zap other variables which became unused due to
this change too.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
192d6f9fa3 ddr: altera: Clean up sdr_*_phase() part 5
Pull out the loop for eaching working/non-working DQS enable phase
into a separate function, as this is mostly common code between.
Clean up sdr_working_phase() and sdr_nonworking_phase() while switching
these two functions to the common sdr_find_phase().

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:19 +02:00
Marek Vasut
38ed692238 ddr: altera: Clean up sdr_*_phase() part 4
Get rid of found_{begin,end} variables. Instead of breaking out
through all of the loops, just return when the begin/end of the
window is found and be done with it. Also clean up the trailing
conditional expression, which is now much easier.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
36edef3c98 ddr: altera: Clean up sdr_*_phase() part 3
Fix the arguments passed to these functions. The bit_chk is
overriden by rw_mgr_mem_calibrate_read_test_all_ranks() which
is invoked by all three sdr_*_phase() functions, so just make
this into local variable.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
521fe39c5f ddr: altera: Clean up sdr_*_phase() part 2
Fix the arguments passed to these functions. The grp argument
does not have to be passed via reference, it's never modified
within either of those functions, so make it into a value.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
0d304ce553 ddr: altera: Clean up sdr_*_phase() part 1
Rename find_working_phase() to sdr_working_phase() for the
sake of consistency.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
0a13a0fb7a ddr: altera: Clean up sdr_find_window_centre() part 3
Reorder the end of the function a little by moving the conditional
debug output around a little. Rename the function from _centre() to
_center(). Document the function in kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
cbb0b7e036 ddr: altera: Clean up sdr_find_window_centre() part 2
This function is a treasure trove of ad-hoc iterative
implementations of mathematical functions. Replace all
of those with their non-iterative counterpart.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
28fd242a18 ddr: altera: Clean up sdr_find_window_centre() part 1
Clean up the arguments of this function. Most of the pointers
passed into the function are either not needed at all, or can
be passed as value instead of reference. Also fix the broken
multiline debug strings. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
28ea827d9c ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay() part 4
This function is only invoked from rw_mgr_mem_calibrate_dqs_enable_calibration()
and at this point, it is just one level of indirection, so wrap the
rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay() into
rw_mgr_mem_calibrate_dqs_enable_calibration() to get rid of the level
of indirection.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
25fefe8bf8 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay() part 3
Replace at least one of the loops in this function with call of a
standard function call instead of the ad-hoc implementation. The
other one cannot be replaced, since the delay is incremented for
each group.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
9da1d8f5b4 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay() part 2
The read_group and write_group params have the same value for all (one)
invocations of this function, just merge them into a single param.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:18 +02:00
Marek Vasut
9059009185 ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay() part 1
Start cleaning up this function. In the first part, just fix
the incorrectly broken debug strings and fix return value to
respect the common convention.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
d844c7d434 ddr: altera: Clean up rw_mgr_mem_calibrate_read_test_patterns()
Rework this function such that the code is more readable. Zap
unused parameter "num_tries" while at it. Also wrap parameter
"bit_chk" into this function as it's value is not used outside.
Finally, fix the return value from this function to match the
common expectation, where 0 means success.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
93dcfd8982 ddr: altera: Zap rw_mgr_mem_calibrate_read_test_patterns_all_ranks()
This function is called from one single place and it's sole purpose
is to call one single function with slightly modified arguments.
Zap this function to skip this useless intermediate step.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
b6cb7f9edd ddr: altera: Minor rw_mgr_mem_calibrate_read_load_patterns() cleanup
Just do an easy data type cleanup of this function, no functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
16cfc4b987 ddr: altera: Extract Centering DQ/DQS from rw_mgr_mem_calibrate_vfifo()
Just extract this piece of functionality into separate function
to make the code better separated. This matches the division in
Altera documentation, Altera EMI_RM 2015.05.04 , section 1, the
UniPHY Calibration Stages.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
f09da11e6b ddr: altera: Extract DQS enable calibration from rw_mgr_mem_calibrate_vfifo()
Just extract this piece of functionality into separate function
to make the code better separated. This matches the division in
Altera documentation, Altera EMI_RM 2015.05.04 , section 1, the
UniPHY Calibration Stages.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
04372fb897 ddr: altera: Extract guaranteed write from rw_mgr_mem_calibrate_vfifo()
Just extract this piece of functionality into separate function
to make the code better separated. This matches the division in
Altera documentation, Altera EMI_RM 2015.05.04 , section 1, the
UniPHY Calibration Stages.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
7c0a9df365 ddr: altera: Internal rw_mgr_mem_calibrate_vfifo() cleanup part 7
Mildly reorder the function so that the reg_file_set*() calls are
in the same place. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
c336ca3e5b ddr: altera: Internal rw_mgr_mem_calibrate_vfifo() cleanup part 6
This is kind of microseries-within-series indent cleanup.
It is clear that the read_group and write_group variables
have the same value, to just make them into one variable
called rw_group. While doing this, constify the variables
as they are constant.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:17 +02:00
Marek Vasut
1e04db4c94 ddr: altera: Internal rw_mgr_mem_calibrate_vfifo() cleanup part 5
This is kind of microseries-within-series indent cleanup.
This patch fixes the broken formatting strings in debug_cond()
invocations.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
fe2d0a2da1 ddr: altera: Internal rw_mgr_mem_calibrate_vfifo() cleanup part 4
This is kind of microseries-within-series indent cleanup.
This patch cleans up the handling of grp_calibrated such
that the variable isn't used all over the place, but just
very localy. This allows trimming down the indent issues.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
ac70d2f387 ddr: altera: Internal rw_mgr_mem_calibrate_vfifo() cleanup part 3
This is kind of microseries-within-series indent cleanup.
This patch just tweaks the indentation so it is visible
what to do with the grp_calibrated variable.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
d2ea49508a ddr: altera: Internal rw_mgr_mem_calibrate_vfifo() cleanup part 2
This is kind of microseries-within-series indent cleanup.
This patch just tweaks the indentation so it is visible
what is supposed to go where.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
bce24efa1d ddr: altera: Internal rw_mgr_mem_calibrate_vfifo() cleanup part 1
This patch just adds an expanded documentation header to the
aforementioned function. This is needed to make it easier to
match the purpose of this function with the documentation.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
8e9d7d04b0 ddr: altera: Minor clean up of rw_mgr_mem_initialize()
Add kerneldoc and do a minor comment cleanup. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
3589fbfbc3 ddr: altera: Internal mem_calibrate() cleanup part 6
Add kerneldoc to this function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
c452dcd0b7 ddr: altera: Internal mem_calibrate() cleanup part 5
This is kind of microseries-within-series indent cleanup.
Rework the code for the the middle-loop of the mega-loop
this time and deal with the group_failed variable. Instead
of checking if the group failed in the previous calibration
part, just jump to the end of the loop if calibration did
fail and increment the counter. This shaves away one more
level of indent while making the code slightly more readable.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
c50ae30341 ddr: altera: Internal mem_calibrate() cleanup part 4
This is kind of microseries-within-series indent cleanup.
Rework the code for the last loop within the mega-loop
to make it actually readable and not an insane cryptic pile
of indent failure.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:16 +02:00
Marek Vasut
8213609e68 ddr: altera: Internal mem_calibrate() cleanup part 3
This is kind of microseries-within-series indent cleanup.
Rework the code for the third loop within the middle-loop
of the mega-loop to make it actually readable and not an
insane cryptic pile of indent failure.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
4ac2161014 ddr: altera: Internal mem_calibrate() cleanup part 2
This is kind of microseries-within-series indent cleanup.
Rework the code for the second loop within the middle-loop
of the mega-loop to make it actually readable and not an
insane cryptic pile of indent failure.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
33c42bb88c ddr: altera: Internal mem_calibrate() cleanup part 1
This is kind of microseries-within-series indent cleanup.
Rework the code for the first loop within the middle-loop
of the mega-loop to make it actually readable and not an
insane cryptic pile of indent failure.

It is likely that this patch has checkpatch warnings, but
for the sake of not breaking the code, these are ignored.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
722c968570 ddr: altera: Trivial mem_calibrate() indent cleanup
Redo the mega-condition such that if the calibration is to be skipped,
the positive branch of the condition does all the work and returns.
The negative branch, which is in fact the default behavior, is then
converted to a code which is no longer conditional. This trims down
the indent by one level.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
51cea0b6c0 ddr: altera: Minor clean up of mem_skip_calibrate()
Perform minor coding style cleanup of the mem_skip_calibrate() function,
clean up comments and add kerneldoc. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
080bf64ef1 ddr: altera: Clean up set_rank_and_odt_mask() part 3
Clean up comments and add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
287cdf6be7 ddr: altera: Clean up set_rank_and_odt_mask() part 2
Turn the big inner if (RW_MGR_MEM_NUMBER_OF_RANKS == ...) conditional
into a switch {} statement instead. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
b2dfd100bc ddr: altera: Clean up set_rank_and_odt_mask() part 1
First, invert the logic of the if (odt_mode == ...) conditional to make
the OFF mode harder to miss. It is a short piece of code right at the
end, so move it up.

Also, clean up data types and constify where applicable and clean up
the cs_and_odt_mask assignment. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
4b0ac26a15 ddr: altera: Clean up mem_precharge_and_activate()
Perform minor cleanup of this function, fix datatype and add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:15 +02:00
Marek Vasut
16502a0b2b ddr: altera: Clean up mem_config()
Clean mem_config() function. First, reorder the math done in the
function such that WLAT and RLAT computation is together. Then,
scrap contradictory comments which do not match the result of the
math at all. Next, extract the mem_precharge_and_activate() call
from the end of the function as it is completely unrelated here.
Finally, rename the function to mem_init_latency().

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
7c89c2d9ce ddr: altera: Clean up phy_mgr_initialize()
Zap the cryptic casts and rework the code into a slightly more
readable form. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
23a040c047 ddr: altera: Clean up run_mem_calibrate()
Clean the function up slightly by using clrsetbits_le32() to flip
bits in registers instead of cryptic bitmasks. Zap condition checking
for PHY_DEBUG_IN_DEBUG_MODE flag, which is never set. Split the
calibration report into separate debug_mem_calibrate() function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
9fa9c90e70 ddr: altera: Rename initialize() to phy_mgr_initialize()
Just perform the rename to make the name more descriptive,
no functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
84e0b0cf2b ddr: altera: Init my_param and my_gbl
Init both structures with zeroes and zap all those zeroing shenanigans
further down in the sdram_calibration_full().

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
880e46f2d3 ddr: altera: Rework initialize_tracking()
Clean the function up by getting rid of all the insane XOR-leftshift
combos when assembling register values. While at it, remove all the
ad-hoc variables necessary for this XOR-leftshift voodoo. Finally,
get rid of the iterative division implementation of two constants
and replace it with a DIV_ROUND_UP() macro :-)

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
d32badbd80 ddr: altera: Fix ad-hoc iterative division implementation
Contemporary CPUs can perform division just fine, use this
functionality and zap another implementation of iterative
division :-)

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
f936f94f80 ddr: altera: Minor clean up of set_jump_as_return()
Add kerneldoc and do a minor comment cleanup.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
ecd2334a17 ddr: altera: Factor out common code
Factor out almost common code from rw_mgr_mem_handoff() and
rw_mgr_mem_initialize() into separate rw_mgr_mem_load_user().
No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:14 +02:00
Marek Vasut
944fe7193e ddr: altera: Factor out instruction loading from rw_mgr_mem_initialize()
Pull the duplicate code out into a separate function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
f51a7d3592 ddr: altera: Clean up scc_mgr_apply_group_all_out_delay_add_all_ranks()
Zap unused group_bgn parameter, fix and constify data types.
Document in kerneldoc. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
5cb1b50870 ddr: altera: Internal scc_mgr_apply_group_all_out_delay_add() cleanup part 2
Clean the DQS and OCT parts of the function, clean up the chopped
formatting strings in debug_cond() and slightly improve the code.
Zap group_bgn argument as it is used only in debug messages. Document
the function using kerneldoc. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
8eccde3ebb ddr: altera: Internal scc_mgr_apply_group_all_out_delay_add() cleanup part 1
Apparently, in case of the DQ and DM, the value if the new_delay variable
is calculated, but the value is not used. Zap the entire code which does
calculate the value.

It is not clear to me whether or not the code is doing the right thing
in the first place. Right now, it calls scc_mgr_load_dq() and
scc_mgr_load_dm() respectively, but I suspect it might need to call
scc_mgr_apply_group_dq_out1_delay() and scc_mgr_apply_group_dm_out1_delay()
instead. This is something Altera must investigate.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
d41ea93a33 ddr: altera: Clean up scc_mgr_zero_group()
First, zap unused argument of the function. Next, clean up
the data types, constify where applicable, clean up comments
and add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
f42af35bdc ddr: altera: Clean up scc_mgr_zero_all()
Add kerneldoc, clean up datatypes and fix minor indentation issue.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
fa5d821b6b ddr: altera: Extract scc_mgr_set_hhp_extras()
Move scc_mgr_set_hhp_extras() out of scc_set_bypass_mode() as it
has nothing to do in there. Instead, invoke it from mem_calibrate()
just before invoking scc_set_bypass_mode().

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
37a37ca7f8 ddr: altera: Clean up scc_mgr_set_hhp_extras()
Minor coding style cleanup for this function. Furthermore, move
ad-hoc debug_cond() calls from the only location from where this
function is invoked into this actual function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
3267524960 ddr: altera: Clean up scc_mgr_*_delay() args
Zap args which are not used by these functions, in particular
the write_group is often passed, but unused.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:13 +02:00
Marek Vasut
300c2e6263 ddr: altera: Clean up scc_mgr_apply_group_dq_out1_delay()
Remove unused write_group and group_bgn argument from this function.
Document the function using kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
5be355c102 ddr: altera: Clean up scc_mgr_set_oct_out1_delay()
Make this function more readable, no functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
c5c5f5378f ddr: altera: Clean up scc_set_bypass_mode()
The mode argument of this function is not used at all, zap it.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
5e83789634 ddr: altera: Clean up scc_mgr_load_dqs_for_write_group()
Make this function more readable, no functional change. Also, zap the
forward declaration, which is no longer needed.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
0b69b807d8 ddr: altera: Implement universal scc_mgr_set_all_ranks()
Implement universal scc_mgr_set_all_ranks() function and convert
various ad-hoc implementations of similar functionality to use
this single function. Document the function in kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
162d60ef73 ddr: altera: Shuffle around scc_mgr_set_*all_ranks()
Shuffle the code around a bit, but without any functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
e893f4dc2f ddr: altera: Clean up scc_mgr_initialize()
Clean up the comments and add kerneldoc. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
c76976d98f ddr: altera: Implement universal scc manager config function
Implement unified scc_mgr_set() function and convert all those
9 scc_mgr_set_*() ad-hoc functions to call this one function.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
5ff825b853 ddr: altera: Reorder scc manager functions
This patch just puts functions which look similar next to each
other, so they can be sorted out. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:12 +02:00
Marek Vasut
07aee5bd98 ddr: altera: Clean up scc manager function args
Clean up the unused args of the functions used to configure the
SCC manager.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
2c0d2d9c40 ddr: altera: Clean up reg_file_set*()
Turn the insides of these functions into trivial clrsetbits_le32()
and fix the data type of their argument to reflect it's actual size.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
2ca151f86c ddr: altera: Clean up initialize_hps_phy()
Add brief kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
9c1ab2ca19 ddr: altera: Clean up initialize_reg_file()
Add brief kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
bb06434bb2 ddr: altera: Clean up hc_initialize_rom_data()
Clean the function up, fix data types, add kerneldoc.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
1273dd9ea3 ddr: altera: Massage addr into I/O accessors
Get rid of invocations of this sort:
  addr = (u32)&base->reg;
  writel(val, addr);

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
6cb9f16781 ddr: altera: Stop using SDR_CTRLGRP_ADDRESS directly
Use the proper structure which describes these registers,
especially since this is already in place.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
17fdc9167f ddr: altera: Wrap SOCFPGA_SDR_ADDRESS into SDR_PHYGRP.*ADDRESS
Just trim down the constant SOCFPGA_SDR_ADDRESS + SDR_PHYGRP.*ADDRESS
in the code.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
c4815f7671 ddr: altera: Pluck out remaining sdr_get_addr() calls
Remove the remaining invocations of sdr_get_addr() and the function
itself. This makes the code a bit less cryptic.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:11 +02:00
Marek Vasut
1bc6f14a61 ddr: altera: Dissolve invocation of sdr_get_addr(&sdr_mgr_.*->.*)
Instead of this indirection, just adjust the register pointer and
directly use the register base address.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:10 +02:00
Marek Vasut
6afb4fe2a0 ddr: altera: Dissolve invocation of sdr_get_addr(&sdr_rw_load.*->.*)
Instead of this indirection, just adjust the register pointer and
directly use the register base address.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:10 +02:00
Marek Vasut
e79025a774 ddr: altera: Dissolve invocation of sdr_get_addr(&sdr_scc_mgr->.*)
Instead of this indirection, just adjust the register pointer and
directly use the register base address.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:10 +02:00
Marek Vasut
a1c654a893 ddr: altera: Dissolve invocation of sdr_get_addr(&sdr_reg_file->.*)
Instead of this indirection, just adjust the register pointer and
directly use the register base address.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:10 +02:00
Marek Vasut
a4bfa463e0 ddr: altera: Zap invocation of sdr_get_addr((u32 *)BASE_RW_MGR)"
Instead of this indirection, just adjust the register pointer and
directly use the register base address.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:10 +02:00
Marek Vasut
23f62b36da ddr: altera: Clean up ugly casts in sdram_calibration_full()
Use the correct formating string in those debug_cond() invocations
and zap those unnecessary ugly casts.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:10 +02:00
Marek Vasut
963bca63b6 ddr: altera: Minor indent fix in set_rank_and_odt_mask()
Fix the position of the } else { statement to make it correctly
indented.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:10 +02:00
Marek Vasut
7ac40d25cf ddr: altera: Fix debug message format in sequencer
The debug messages missed proper newlines and/or spaces in them.
Fix the formatting.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Chin Liang See <clsee@altera.com>
Cc: Dinh Nguyen <dinguyen@altera.com>
Cc: Tom Rini <trini@konsulko.com>
2015-08-08 14:14:06 +02:00
Marek Vasut
452a81e078 ddr: altera: Fix typo in mp_threshold1 programming
It is the configuration data that should go into the register,
not the register mask, just like the surrounding code does it.
Fix this typo.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Chin Liang See <clsee@altera.com>
Cc: Dinh Nguyen <dinguyen@altera.com>
Cc: Tom Rini <trini@konsulko.com>
2015-08-08 14:14:05 +02:00
Marek Vasut
42f7ebb82b ddr: altera: Move struct sdram_prot_rule prototype
Move the structure prototype from sdram.h header file into sdram.c
source file, since it is used only there and for local purpose only.
There is no point in having it global.

While at this move, fix the data types in the structure from uintNN_t
to uNN and fix the coding style a bit.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:05 +02:00
Marek Vasut
d04941cf33 arm: socfpga: Move sdram_config.h to board dir
This file is absolutelly positively board specific, so move it
into the correct place.

Signed-off-by: Marek Vasut <marex@denx.de>
2015-08-08 14:14:05 +02:00
Dinh Nguyen
3da428595e driver/ddr/altera: Add the sdram calibration portion
This patch adds the DDR calibration portion of the Altera SDRAM driver.

Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
2015-08-08 14:14:05 +02:00
Dinh Nguyen
9bbd2132e3 driver/ddr/altera: Add DDR driver for Altera's SDRAM controller
This patch enables the SDRAM controller that is used on Altera's SoCFPGA
family. This patch configures the SDRAM controller based on a configuration
file that is generated from the Quartus tool, sdram_config.h.

Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
2015-08-08 14:14:05 +02:00
Marek Vasut
9f76f105c7 net: designware: Rename the driver var name to eth_designware
The driver variable name is eth_sandbox, which is probably a copy-paste
mistake. Fix it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2015-08-08 14:14:05 +02:00
Marek Vasut
b9628595b4 net: designware: Add SoCFPGA GMAC DT compatible string
Add the OF compatible property to match the SoCFPGA GMAC.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2015-08-08 14:14:05 +02:00
Marek Vasut
bfa89d2ba8 arm: socfpga: Fix FPGA bitstream programming routine
In case the FPGA bitstream is aligned to 4 bytes, skip the
part of the assembler which handles unaligned bitstream.
Otherwise, that part will loop indefinitelly.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
2015-08-08 14:14:04 +02:00
Tom Rini
ae27120c31 Merge git://git.denx.de/u-boot-dm 2015-08-06 19:56:03 -04:00
Simon Glass
f5c67ea036 dm: core: Add a way to set a device name
Some devices are bound entirely by probing and do not have the benefit of
a device tree to give them a name. This is very common with PCI and USB. In
most cases this is fine, but we should add an official way to set a device
name. This should be called in the device's bind() method.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-06 07:44:29 -06:00
Masahiro Yamada
40b6f2d020 devres: add debug command to dump device resources
This new command can dump all device resources associated to
each device.  The fields in every line shows:
  - The address of the resource
  - The size of the resource
  - The name of the release function
  - The stage in which the resource has been acquired (BIND/PROBE)

Currently, there is no driver using devres, but if such drivers are
implemented, the output of this command should look like this:

=> dm devres
- root_driver
- soc
- extbus
- serial@54006800
    bfb541e8 (8 byte) devm_kmalloc_release  BIND
    bfb54440 (4 byte) devm_kmalloc_release  PROBE
    bfb54460 (4 byte) devm_kmalloc_release  PROBE
- serial@54006900
    bfb54270 (8 byte) devm_kmalloc_release  BIND
- gpio@55000000
- i2c@58780000
    bfb5bce8 (12 byte) devm_kmalloc_release  PROBE
    bfb5bd10 (4 byte) devm_kmalloc_release  PROBE
- eeprom
    bfb54418 (12 byte) devm_kmalloc_release  BIND

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:29 -06:00
Masahiro Yamada
e2282d7076 devres: make Devres optional with CONFIG_DEVRES
Currently, Devres requires additional 16 byte for each allocation,
which is not so insignificant in some cases.

Add CONFIG_DEVRES to make this framework optional.
If the option is disabled, devres functions fall back to
non-managed variants.  For example, devres_alloc() to kzalloc(),
devm_kmalloc() to kmalloc(), etc.

Because devres_head is also surrounded by an ifdef conditional,
there is no memory overhead when CONFIG_DEVRES is disabled.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Suggested-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:29 -06:00
Masahiro Yamada
2b07f6859a devres: add devm_kmalloc() and friends (managed memory allocators)
devm_kmalloc() is identical to kmalloc() except that the memory
allocated with it is managed and will be automatically released
when the device is removed/unbound.

Likewise for the other variants.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:29 -06:00
Masahiro Yamada
608f26c51b devres: introduce Devres (Managed Device Resource) framework
In U-Boot's driver model, memory is basically allocated and freed
in the core framework.  So, low level drivers generally only have
to specify the size of needed memory with .priv_auto_alloc_size,
.platdata_auto_alloc_size, etc.  Nevertheless, some drivers still
need to allocate/free memory on their own in case they cannot
statically know the necessary memory size.  So, I believe it is
reasonable enough to port Devres into U-boot.

Devres, which originates in Linux, manages device resources for each
device and automatically releases them on driver detach.  With devres,
device resources are guaranteed to be freed whether initialization
fails half-way or the device gets detached.

The basic idea is totally the same to that of Linux, but I tweaked
it a bit so that it fits in U-Boot's driver model.

In U-Boot, drivers are activated in two steps: binding and probing.
Binding puts a driver and a device together.  It is just data
manipulation on the system memory, so nothing has happened on the
hardware device at this moment.  When the device is really used, it
is probed.  Probing initializes the real hardware device to make it
really ready for use.

So, the resources acquired during the probing process must be freed
when the device is removed.  Likewise, what has been allocated in
binding should be released when the device is unbound.  The struct
devres has a member "probe" to remember when the resource was
allocated.

CONFIG_DEBUG_DEVRES is also supported for easier debugging.
If enabled, debug messages are printed each time a resource is
allocated/freed.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:29 -06:00
Masahiro Yamada
aed1a4dd88 dm: add DM_FLAG_BOUND flag
Currently, we only have DM_FLAG_ACTIVATED to indicate the device
status, but we still cannot know in which stage is in progress,
binding or probing.

This commit introduces a new flag, DM_FLAG_BOUND, which is set when
the device is really bound, and cleared when it is unbound.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:29 -06:00
Simon Glass
f33017716e dm: Support address translation for simple-bus
The 'ranges' property can be used to specify a translation from the system
address to the bus address. Add support for this using the dev_get_addr()
function, which devices should use to find their address.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:28 -06:00
Simon Glass
0990fcb772 net: smsc95xx: Add driver-model support
Add support for driver model, so that CONFIG_DM_ETH can be defined and used
with this driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:28 -06:00
Simon Glass
527298c4b5 net: smsc95xx: Prepare for conversion to driver model
At present struct eth_device is passed around all over the place. This does
not exist with driver model. Add explicit arguments instead, so that with
driver model we can pass the correct things.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:44:27 -06:00
Simon Glass
25a9e98038 net: smsc95xx: Correct the error numbers
Instead of returning -1 on error, we should use a proper error number. Fix
the code to conform to this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:40:45 -06:00
Simon Glass
d62a1dc6bc net: smsc95xx: Rename AX_RX_URB_SIZE to RX_URB_SIZE
The AX_ prefix comes from the Asix driver. Since this is not that, we should
avoid this confusing prefix.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:31:37 -06:00
Simon Glass
a26925913c net: smsc95xx: Sort the include files
Tidy up the include file order before adding more.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:31:37 -06:00
Simon Glass
f58a41e001 dm: usb: Add driver-model support to dwc2
Add driver model support to this driver so it can be used with the new USB
stack.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:31:37 -06:00
Simon Glass
cc3e3a9e0e dm: usb: Prepare dwc2 driver for driver-model conversion
Put all global data in a structure and move (what will be) common code into
common functions. This will make the driver-model conversion much easier.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:31:37 -06:00
Simon Glass
2e5350fee0 dm: usb: Add an errno.h header to usb_ether.c
This is required on some platforms, so add it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:31:36 -06:00
Simon Glass
12dc8e7522 dm: Make regmap and syscon optional
Not all boards use garbage collection in their link step, so we should avoid
adding options that rely on this for prevention of code bloat. Add separate
Kconfig options for syscon and regmap uclasses.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-06 07:31:36 -06:00
York Sun
fdb9f349be lib/fdtdec: Fix compiling warning caused by changing fdt_addr_t type
fdt_addr_t is changed to phys_addr_t. The format in debug should be updated
to %pa to match the type.

Signed-off-by: York Sun <yorksun@freescale.com>
CC: Simon Glass <sjg@chromium.org>
2015-08-06 07:31:13 -06:00
Simon Glass
a7a73ef85f exynos: video: Remove non-device-tree code
We always use device tree on exynos, so remove the unused code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:17 -06:00
Simon Glass
68964dbc83 video: Remove the old parade driver
We have a new one which uses driver model and device tree configuration.
Remove the old one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:16 -06:00
Simon Glass
24696e2f21 cros_ec: Remove the old tunnel code
This is not needed with driver mode. Remove it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:16 -06:00
Simon Glass
05bccbcd76 power: Remove old TPS65090 drivers
Remove the old drivers (both the normal one and the cros_ec one) now that
we have new drivers that use driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:16 -06:00
Simon Glass
eca4866586 dm: gpio: Check a GPIO is valid before using it
Since a gpio_desc is allowed to be invalid we should return an error
indicating that the operation cannot be completed. This can happen if the
GPIO is optional - e.g. some devices may have a reset line and some may
not.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:14 -06:00
Simon Glass
129c942f32 exynos: video: Correct debug output
We should not print a message from the driver when the display is set up.
This is normal behaviour. Change this message to use debug().

Also remove the double newline on another debug message.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:14 -06:00
Simon Glass
c95ed7d9e7 exynos: Correct return value in exynos_mmc_init()
This function should return 0 on success, not 1. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:14 -06:00
Simon Glass
c7d50e7fb9 exynos: spi: Convert the timeout to debug()
Since the timeout is reported through normal channels, and is sometimes
expected (e.g. if the bus is being probed for a non-existent device),
don't display the message in the driver.

In general, drivers should not write to the console as this limits their
usefulness in error conditions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:14 -06:00
Simon Glass
048dba0191 dm: video: Add support for the NXP PTN3460 bridge
This chip provides an eDP to LVDS bridge which is useful for SoCs that don't
support LVDS displays (or it would waste scarce pins). There is no setup
required by this chip, other than to adjust power-down and reset pins, and
those are managed by the uclass.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:13 -06:00
Simon Glass
bcd5dfffe6 dm: video: Add support for the Parade PS8622/625 bridge
This chip provides an eDP to LVDS bridge which is useful for SoCs that don't
support LVDS displays (or it would waste scarce pins). The setup is included
in the device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:13 -06:00
Simon Glass
5eaeadaa3a video: Work around lack of pinctrl
We haven't quite got pinctrl ready to apply to mainline. We don't want to
GPIO pull-up/down support to the driver model GPIO layer either. So work
around this for now.

We can address this when pinctrl is complete.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:13 -06:00
Simon Glass
801ab9e93c dm: video: Add support for video bridges
A video bridge typically converts video from one format to another, e.g.
DisplayPort to LVDS. Add driver model support for these with a simple
interface to control activation and backlight. The uclass supports GPIO
control of power and reset lines.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:13 -06:00
Simon Glass
d08504d18a dm: power: Don't return an error when regulators are not autoset
Not all regulators can be set up automatically. Adjust the code so that
regulators_enable_boot_on() will return success when some are skipped.
Only genuine errors are reported.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:13 -06:00
Simon Glass
75a429f1a2 dm: pmic: max77686: Support all BUCK regulators
Add support for all BUCK regulators, now that the correct register is
accessed for each.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:13 -06:00
Simon Glass
8c4287090c dm: power: max77686: Correct BUCK register access
Some regulators use the wrong voltage register and thus it is not possible
to control them. Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:12 -06:00
Simon Glass
cd367d8997 dm: pmic: Correct the pmic_reg_write() implementation
This should write the register, not read it. Fix this bug.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:12 -06:00
Simon Glass
b5ffa4fdcb dm: pmic: max77686: Correct a few nits
The driver name should not have a space in it. Also the regulator names
should match the case of the device tree. Fix these problems.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:12 -06:00
Simon Glass
f615e6a64d dm: power: Add support for S5M8767 regulators
This PMIC is used with SoCs which need a combination of BUCKs and LDOs. The
driver supports changing voltage and enabling/disabling each regulator. It
supports the standard device tree binding and supports driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:12 -06:00
Simon Glass
d308c0136d dm: power: Add support for the S5M8767 PMIC
This PMIC is used with SoCs which need a combination of BUCKs and LDOs. The
driver supports probing and basic register access. It supports the standard
device tree binding and supports driver model. A regulator driver can be
provided also.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:12 -06:00
Simon Glass
1c88b67ec8 dm: power: Add support for TPS65090 FETs
The TPS65090 has 7 FETs which are modelled as regulators. This allows them
to be controlled by drivers easier, accessed through the 'regulator' command
and used by other drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:12 -06:00
Simon Glass
151b223b9c dm: power: Add a new driver for the TPS65090 PMIC
The existing TPS65090 driver does not support driver model. Add a new one
that does. This can be used as a base for a regulator driver also. It uses
the standard device tree binding.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
2015-08-05 21:06:12 -06:00
Simon Glass
7fb57396e6 exynos: Enable the debug UART in SPL
As a debugging aid, allow UART3 to be used as a debug UART in SPL. This
is a precursor to proper UART support, which requires a substantial
refactor.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:11 -06:00
Simon Glass
bf6e702232 exynos: Add debug UART support for Samsung S5P serial
Add a debug UART implementation for this serial driver. It does not set up
pinmux automatically - this must be done before calling debug_uart_init().

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:11 -06:00
Simon Glass
89ca9351cf exynos: serial: Refactor init code for debug UART
The debug UART code needs to perform the same init as the normal UART
driver. In preparation for this, move the init code into two functions, one
for the basic init and one for setting the baud rate. This will make adding
debug UART support easier.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:11 -06:00
Simon Glass
f48eaf01b2 cros_ec: Support the LDO access method used by spring
Add a driver to support the special LDO access used by spring. This is a
custom method in the cros_ec protocol - it does not use an I2C
pass-through.

There are two implementation choices:

1. Write a special LDO driver which can talk across the EC. Duplicate all
the logic from TPS65090 for retrying when the LDO fails to come up.

2. Write a special I2C bus driver which pretends to be a TPS65090 and
transfers reads and writes using the LDO message.

Either is distasteful. The latter method is chosen since it results in less
code duplication and a fairly simple (30-line) implementation of the core
logic.

The crosec 'ldo' subcommand could be removed (since i2c md/mw will work
instead) but is retained as a convenience.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:11 -06:00
Simon Glass
cc456bd7df dm: cros_ec: Convert the I2C tunnel code to use driver model
The Chrome OS EC supports tunnelling through to an I2C bus on the EC. This
currently uses a copy of the I2C command code and a special 'crosec'
sub-command.

With driver model we can define an I2C bus which tunnels through to the EC,
and use the normal 'i2c' command to access it. This simplifies the code and
removes some duplication.

Add an I2C driver which tunnels through to the EC. Adjust the EC code to
support binding child devices so that it can be set up. Adjust the existing
I2C xfer function to fit driver model better.

For now the old code remains to allow things to still work. It will be
removed in a later patch once the new flow is fully enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:11 -06:00
Simon Glass
45d9ae87cb exynos: i2c: Tidy up the driver model code
The existing driver model implementation uses the old non-driver-model code
to operate, but has become impossibly tangled as a result. The actual
algorithm is quite simple.

Also the normal-speed and high-speed buses are quite different and it
doesn't seem that useful to put them in the same driver.

Finally, there is a bug which breaks communication with the Maxim sound
codec and may cause problems with other device.

Rewrite the driver model code for normal-speed operation so that it is
easier to understand, and fix the bug. Add a TODO to split the drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
2015-08-05 21:06:10 -06:00
Simon Glass
26ea76850e exynos: i2c: Fix code style with ReadWriteByte()
This function should not use mixed case, and it is simpler to use
clrbits_le32() when clearing bits. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
2015-08-05 21:06:10 -06:00
Simon Glass
b725dc458f i2c: Add a mux for GPIO-based I2C bus arbitration
While I2C supports multi-master buses this is difficult to get right.
The implementation on the master side in software is quite complex.
Clock-stretching and the arbitrary time that an I2C transaction can take
make it difficult to share the bus fairly in the face of high traffic.
When one or more masters can be reset independently part-way through a
transaction it is hard to know the state of the bus.

This driver provides a scheme based on two 'claim' GPIOs, one driven by the
AP (Application Processor, meaning the main CPU) and one driven by the EC
(Embedded Controller, a small CPU aimed at handling system tasks). With
these they can communicate and reliably share the bus. This scheme has
minimal overhead and involves very little code. It is used on snow to
permit the EC and the AP to share access to the main system PMIC and
battery. The scheme can survive reboots by either side without difficulty.
This scheme has been tested in the field with millions of devices.

Since U-Boot runs on the AP, the terminology used is 'our' claim GPIO,
meaning the AP's, and 'their' claim GPIO, meaning the EC's. This terminology
is used by the device tree bindings in Linux also.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:10 -06:00
Simon Glass
3d1957f0ea dm: i2c: Add support for multiplexed I2C buses
Add a new I2C_MUX uclass. Devices in this class can multiplex between
several I2C buses, selecting them one at a time for use by the system.
The multiplexing mechanism is left to the driver to decide - it may be
controlled by GPIOs, for example.

The uclass supports only two methods: select() and deselect().

The current mux state is expected to be stored in the mux itself since
it is the only thing that knows how to make things work. The mux can
record the current state and then avoid switching unless it is necessary.
So select() can be skipped if the mux is already in the correct state.
Also deselect() can be made a nop if required.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 21:06:10 -06:00
Simon Glass
df358c6bec dm: i2c: Add a function to transfer messages
Sometimes it is useful to be able to transfer a raw I2C message. This
happens when the chip address needs to be set manually, or when the data to
be sent/received is in another buffer.

Add a function to provide access to this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
2015-08-05 20:57:51 -06:00
Simon Glass
7d7db2225c dm: i2c: Add a message debug function
Add a way to dump the contents of an I2C message for debugging purposes.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
2015-08-05 20:57:51 -06:00
Simon Glass
d82ba4c0b4 dm: core: Support finding a device by phandle
It is common for one node to reference another via a phandle. Add support
for obtaining an attached device by this method. As an example, a node may
have a 'power-supply' property which references a regulator, allowing the
driver to turn on its power.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-08-05 20:57:51 -06:00
Tom Warren
3e8650c0f9 Tegra: clocks: Add 38.4MHz OSC support for T210 use
Added 38.4MHz/48MHz entries to pll_x_table for CPU PLL. Needs
to be measured - should be close to 700MHz (1.4G/2).

Note that some freqs aren't in the PLLU table in T210 TRM
(13, 26MHz), so I used the 12MHz table entry for them. They
shouldn't be selected since they're not viable T210 OSC freqs.

Since there are now 2 new OSC defines, all tables (pll_x_table,
PLLU) had to increase by two entries, but since 38.4/48MHz are
not viable osc freqs on T20/30/114, etc, they're just set to 0.

Signed-off-by: Tom Warren <twarren@nvidia.com>
2015-08-05 15:22:51 -07:00
Tom Rini
1a2728ae4f Merge git://git.denx.de/u-boot-x86 2015-08-05 14:12:37 -04:00
Bin Meng
ae0518200f pci: Remove DEBUG from pci_compat.c
Remove DEBUG in drivers/pci/pci_compat.c.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-05 10:49:32 -06:00
Marcel Ziswiler
147271209a net: asix: fix operation without eeprom
This patch fixes operation of our on-board AX88772B chip without EEPROM
but with a ethaddr coming from the regular U-Boot environment. This is
a forward port of some remaining parts initially implemented by
Antmicro.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Acked-by: Marek Vasut <marex@denx.de>
2015-08-05 17:20:35 +02:00
Paul Kocialkowski
0fa5999bea usb: USB storage-specific part ifdef in uclass
usb_stor_reset is only defined when USB storage support is enabled, thus the
function is not declared when such support is missing.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-08-05 17:20:34 +02:00
Maxime Ripard
1feda63ed9 musb: sunxi: Force EP0 on re-enable
Currently, the second use of a gadget will fail, while the first one works.

Forcing the EP0 at every enable fix this issue.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2015-08-05 17:20:34 +02:00
Paul Kocialkowski
6bed24cc62 sunxi: usb: USB_MUSB_SUNXI move to musb-new Kconfig
Now that the musb-new driver has a Kconfig, we can move Kconfig options to
enable controllers to it, so that it's easier in e.g. menuconfig.

In addition, this allows declaring support for USB_MUSB_HOST/GADGET in
defconfigs instead of the USB_MUSB_SUNXI controller, that will get selected
automatically when needed.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-08-05 17:20:34 +02:00
Paul Kocialkowski
5d6c2f4b5a usb: musb-new: Kconfig support for USB_MUSB_HOST and USB_MUSB_GADGET
Having MUSB_HOST and MUSB_GADGET in Kconfig allows more flexibility with regard
to what Kconfig options to enable, such as USB_STORAGE or USB_KEYBOARD.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-08-05 17:20:34 +02:00
Paul Kocialkowski
95de1e2f26 usb: musb-new: CONFIG_MUSB prefix replacement with CONFIG_USB_MUSB
USB-related options are usually prefixed with CONFIG_USB and platform-specific
adaptation for the MUSB controller already have a CONFIG_USB_MUSB prefix, so
this switches all MUSB-related options to a CONFIG_USB_MUSB prefix, for
consistency.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-08-05 17:20:34 +02:00
Paul Kocialkowski
68f7c5db2d usb: Generic USB Kconfig option, that fits both host and gadget and comments
There is no particular reason why the USB Kconfig option should be specific to
host mode. In prevision of adding MUSB host and gadget to Kconfig, this moves
the title and help message of the USB Kconfig option to a more generic format.

Adding comments to the usb Kconfig allows for a better separation and more
readability in generated configs and in menuconfig.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-08-05 17:20:34 +02:00
Paul Kocialkowski
9ad437447d usb: USB_ARCH_HAS_HCD Kconfig option removal
The USB_ARCH_HAS_HCD currently serves no purpose and adds some confusion to the
required Kconfig options that are required to have USB support.

Dropping it makes things easier and doesn't break anything, since it was unused
anyways.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-08-05 17:20:34 +02:00
Peter Griffin
93b9957894 usb: dwc2: Call board_usb_init() from usb_lowlevel_init()
This patch makes the dwc2 controller like ehci / ohci / xhci controllers
by calling the board_usb_init() function from usb_lowlevel_init.

This can then be implemented by specific platforms to initialise
their USB hardware (phys / clocks etc).

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
2015-08-05 17:20:34 +02:00
Simon Glass
ad11dbff74 x86: Gracefully disable the vesa driver when running from EFI
We cannot use this driver when running from EFI as we have no direct hardware
access. In fact coreboot uses a different driver which uses tables provided
by coreboot. So far it does not seem possible to use a normal video driver
when booting from EFI.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:44:08 -06:00
Simon Glass
275854baee efi: Add a serial driver
Add a serial driver which makes use of EFI's console in/out service.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested on Intel Crown Bay and QEMU
Tested-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:44:05 -06:00
Simon Glass
dcfe4a54ed x86: Move CONFIG_X86_SERIAL to Kconfig
Move this config option to Kconfig and tidy up.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:42 -06:00
Simon Glass
4bad2e7374 pci: Indicate prefetchable memory allocate when debugging
At present the PCI output displays 'Mem' when it allocates memory for a PCI
device, whether it is prefetchable or not. There is a distinction since the
memory comes from separate pools. Use 'Prf' instead of 'Mem' when allocating
prefetchable memory.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:41 -06:00
Simon Glass
5f48d798eb pci: Add a constant for an invalid interrupt
Rather than using 0xff in the code, add a constant.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:41 -06:00
Simon Glass
53292ad956 pci: Fix up code for CONFIG_PCI_ENUM_ONLY
This option is not used by any board but appears to still be useful, at least
for testing. With recent commits it does not build, so fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:41 -06:00
Simon Glass
da4b159bf0 pci: Use debug() instead of DEBUGF() in pci_auto.c
This file does not need its own way of doing debug(). Clean it up to use the
new way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Pavel Machek <pavel@denx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:41 -06:00
Simon Glass
8b097916fa x86: Add some missing global_data declarations in files that use gd
Some files use global_data but don't declare it. Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:41 -06:00
Simon Glass
753812cb2e dm: serial: Correct logic in serial_find_console_or_panic()
In a final attempt to find a console UART this function uses the first
first available serial device. However the check for a valid device is
inverted.

This code is only executed when there is in fact no serial UART, but at
present it can fail to reach the panic_str() call in this case, and start
trying to use a non-existent UART.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:40 -06:00
Simon Glass
2fda14ae6a dm: core: Check for empty list in uclass_find_device()
This function needs to check the list has entries before traversing it.
Fix this bug.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-08-05 08:42:40 -06:00
Bin Meng
1e7a047304 x86: Sanity test on vesa parameters before setting up kernel screen_info
We should not set up kernel screen_info when the vesa parameters are
insane, otherwise kernel will panic.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-05 08:42:38 -06:00
Bin Meng
df189d9ba3 dm: pci: Allow scan bridge child devices before relocation
On some platforms pci devices behind bridge need to be probed (eg:
a pci uart on recent x86 chipset) before relocation. Remove such
limitation so that dm pci can be used before relocation.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-08-05 08:42:38 -06:00
York Sun
56848428a8 drivers/ddr/fsl: Adjust bstopre value
By default the bstopre value has been set to 0x100, used to be 1/4
value of refint. Modern DDR has increased the refresh time. Adjust
to 1/4 of refresh interval dynamically. Individual board can still
override this value in board ddr file, or to use auto-precharge.

Signed-off-by: York Sun <yorksun@freescale.com>
2015-08-03 12:06:38 -07:00
horia.geanta@freescale.com
14d5547cf1 drivers/crypto/fsl: clean-up - use fdt_setprop_u32 helper
Signed-off-by: Horia Geantă <horia.geanta@freescale.com>
Acked-by: Ruchika Gupta<ruchika.gupta@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
2015-08-03 12:06:38 -07:00
horia.geanta@freescale.com
3ef2412de6 drivers/crypto/fsl: fix snooping for write transactions
HW coherency won't work properly for CAAM write transactions
if AWCACHE is left to default (POR) value - 4'b0001.
It has to be programmed to 4'b0010.

For platforms that have HW coherency support:
-PPC-based: the update has no effect; CAAM coherency already works
due to the IOMMU (PAMU) driver setting the correct memory coherency
attributes
-ARM-based: the update fixes cache coherency issues,
since IOMMU (SMMU) driver is not programmed to behave similar to PAMU

Fixes: b9eebfade9 ("fsl_sec: Add hardware accelerated SHA256 and SHA1")
Signed-off-by: Horia Geantă <horia.geanta@freescale.com>
Reviewed-by: Aneesh Bansal <aneesh.bansal@freescale.com>
Reviewed-by: Mingkai Hu <Mingkai.Hu@freescale.com>
Acked-by: Ruchika Gupta<ruchika.gupta@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
2015-08-03 12:06:38 -07:00
horia.geanta@freescale.com
e5d08b4d60 drivers/crypto/fsl: fix "era" property value on LE platforms
Use fdt_setprop_u32() instead of fdt_setprop().

Fixes: 0181937fa3 ("crypto/fsl: Add fixup for crypto node")
Signed-off-by: Horia Geantă <horia.geanta@freescale.com>
Reviewed-by: Mingkai Hu <Mingkai.Hu@freescale.com>
Acked-by: Ruchika Gupta<ruchika.gupta@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
2015-08-03 12:06:38 -07:00
Minghuan Lian
01cafcedbf drivers/pci/layerscape: Add EP mode support
The patch will initialize PCIe controller on EP mode
1. Setup bar:
   bar0 32bit 4K for specific configuration
   bar1 32bit 8K for MSIX
   bar2 64bit 4K for descriptor of memory
   bar4 64bit 1M for DMA memory test
2. Setup iATU:
   iATU inbound 0-3 to map bar transaction to memory address
   started at CONFIG_SYS_PCI_EP_MEMORY_BASE
   iATU outbound 0 to map 4G memory space

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
2015-08-03 12:06:38 -07:00
Minghuan Lian
ed5b580b38 drivers/pci: Add function to find an extended capability
PCIe extends device's configuration space to 4k and provides
extended capability. The patch adds function to find them.
The code is ported from Linux PCIe driver.

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: York Sun <yorksun@freescale.com>
2015-08-03 12:06:38 -07:00