blob: b4939519ced2f56c8cda8b128c1ad859e6ad5b6c [file] [log] [blame]
Bernhard Messerklingerd9461aa2020-05-18 12:33:34 +02001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright 2019 Google LLC
4 * Copyright 2020 B&R Industrial Automation GmbH - http://www.br-automation.com
5 */
6
7#ifndef __ASM_ARCH_FSP_BINDINGS_H
8#define __ASM_ARCH_FSP_BINDINGS_H
9
10#include <asm/arch/fsp/fsp_m_upd.h>
Bernhard Messerklingerd65763c2020-05-18 12:33:35 +020011#include <asm/arch/fsp/fsp_s_upd.h>
Bernhard Messerklingerd9461aa2020-05-18 12:33:34 +020012
13#define ARRAY_SIZE_OF_MEMBER(s, m) (ARRAY_SIZE((((s *)0)->m)))
14#define SIZE_OF_MEMBER(s, m) (sizeof((((s *)0)->m)))
15
16enum conf_type {
17 FSP_UINT8,
18 FSP_UINT16,
19 FSP_UINT32,
20 FSP_STRING,
21 FSP_LPDDR4_SWIZZLE,
22};
23
24/**
25 * struct fsp_binding - Binding describing devicetree/FSP relationships
26 * @offset: Offset within the FSP config structure
27 * @propname: Name of property to read
28 * @type: Type of the property to read
29 * @count: If the property is expected to be an array, this is the
30 * number of expected elements
31 * Set to 0 if the property is expected to be a scalar
32 *
33 * The struct fsp_binding is used to describe the relationship between
34 * values stored in devicetree and where they are placed in the FSP
35 * configuration structure.
36 */
37struct fsp_binding {
38 size_t offset;
39 char *propname;
40 enum conf_type type;
41 size_t count;
42};
43
44/*
45 * LPDDR4 helper routines for configuring the memory UPD for LPDDR4 operation.
46 * There are four physical LPDDR4 channels, each 32-bits wide. There are two
47 * logical channels using two physical channels together to form a 64-bit
48 * interface to memory for each logical channel.
49 */
50
51enum {
52 LP4_PHYS_CH0A,
53 LP4_PHYS_CH0B,
54 LP4_PHYS_CH1A,
55 LP4_PHYS_CH1B,
56
57 LP4_NUM_PHYS_CHANNELS,
58};
59
60/*
61 * The DQs within a physical channel can be bit-swizzled within each byte.
62 * Within a channel the bytes can be swapped, but the DQs need to be routed
63 * with the corresponding DQS (strobe).
64 */
65enum {
66 LP4_DQS0,
67 LP4_DQS1,
68 LP4_DQS2,
69 LP4_DQS3,
70
71 LP4_NUM_BYTE_LANES,
72 DQ_BITS_PER_DQS = 8,
73};
74
75/* Provide bit swizzling per DQS and byte swapping within a channel */
76struct lpddr4_chan_swizzle_cfg {
77 u8 dqs[LP4_NUM_BYTE_LANES][DQ_BITS_PER_DQS];
78};
79
80struct lpddr4_swizzle_cfg {
81 struct lpddr4_chan_swizzle_cfg phys[LP4_NUM_PHYS_CHANNELS];
82};
83
84/**
85 * fsp_m_update_config_from_dtb() - Read FSP-M config from devicetree node
86 * @node: Valid node reference to read property from
87 * @cfg: Pointer to FSP-M config structure
88 * @return 0 on success, -ve on error
89 *
90 * This function reads the configuration for FSP-M from the provided
91 * devicetree node and saves it in the FSP-M configuration structure.
92 * Configuration options that are not present in the devicetree are
93 * left at their current value.
94 */
95int fsp_m_update_config_from_dtb(ofnode node, struct fsp_m_config *cfg);
96
Bernhard Messerklingerd65763c2020-05-18 12:33:35 +020097/**
98 * fsp_s_update_config_from_dtb() - Read FSP-S config from devicetree node
99 * @node: Valid node reference to read property from
100 * @cfg: Pointer to FSP-S config structure
101 * @return 0 on success, -ve on error
102 *
103 * This function reads the configuration for FSP-S from the provided
104 * devicetree node and saves it in the FSP-S configuration structure.
105 * Configuration options that are not present in the devicetree are
106 * left at their current value.
107 */
108int fsp_s_update_config_from_dtb(ofnode node, struct fsp_s_config *cfg);
109
Bernhard Messerklingerd9461aa2020-05-18 12:33:34 +0200110#endif