Commit d85cd291331b07df57fd4ada84d2c7b9b76ac1b8

Authored by Tom Rini

Merge git://git.denx.de/u-boot-dm

Showing 10 changed files Side-by-side Diff

arch/sandbox/cpu/cpu.c
... ... @@ -22,6 +22,8 @@
22 22  
23 23 void reset_cpu(ulong ignored)
24 24 {
  25 + /* Do this here while it still has an effect */
  26 + os_fd_restore();
25 27 if (state_uninit())
26 28 os_exit(2);
27 29  
arch/sandbox/cpu/os.c
... ... @@ -107,10 +107,12 @@
107 107 static struct termios orig_term;
108 108 static bool term_setup;
109 109  
110   -static void os_fd_restore(void)
  110 +void os_fd_restore(void)
111 111 {
112   - if (term_setup)
  112 + if (term_setup) {
113 113 tcsetattr(0, TCSANOW, &orig_term);
  114 + term_setup = false;
  115 + }
114 116 }
115 117  
116 118 /* Put tty into raw mode so <tab> and <ctrl+c> work */
... ... @@ -120,7 +122,6 @@
120 122  
121 123 if (term_setup)
122 124 return;
123   - term_setup = true;
124 125  
125 126 /* If not a tty, don't complain */
126 127 if (tcgetattr(fd, &orig_term))
... ... @@ -134,6 +135,7 @@
134 135 if (tcsetattr(fd, TCSANOW, &term))
135 136 return;
136 137  
  138 + term_setup = true;
137 139 atexit(os_fd_restore);
138 140 }
139 141  
arch/sandbox/dts/Makefile
1 1 dtb-$(CONFIG_SANDBOX) += sandbox.dtb
2   -dtb-$(CONFIG_DM_TEST) += test.dtb
  2 +dtb-$(CONFIG_UT_DM) += test.dtb
3 3  
4 4 targets += $(dtb-y)
5 5  
arch/sandbox/dts/sandbox.dts
... ... @@ -17,30 +17,6 @@
17 17 stdout-path = "/serial";
18 18 };
19 19  
20   - /* Needs to be available prior to relocation */
21   - uart0: serial {
22   - compatible = "sandbox,serial";
23   - sandbox,text-colour = "cyan";
24   - };
25   -
26   - triangle {
27   - compatible = "demo-shape";
28   - colour = "cyan";
29   - sides = <3>;
30   - character = <83>;
31   - light-gpios = <&gpio_a 2>, <&gpio_b 6 0>;
32   - };
33   - square {
34   - compatible = "demo-shape";
35   - colour = "blue";
36   - sides = <4>;
37   - };
38   - hexagon {
39   - compatible = "demo-simple";
40   - colour = "white";
41   - sides = <6>;
42   - };
43   -
44 20 cros_ec: cros-ec@0 {
45 21 reg = <0 0>;
46 22 compatible = "google,cros-ec-sandbox";
47 23  
... ... @@ -70,12 +46,24 @@
70 46 };
71 47 };
72 48  
73   - lcd {
74   - compatible = "sandbox,lcd-sdl";
75   - xres = <1366>;
76   - yres = <768>;
  49 + eth@10002000 {
  50 + compatible = "sandbox,eth";
  51 + reg = <0x10002000 0x1000>;
  52 + fake-host-hwaddr = [00 00 66 44 22 00];
77 53 };
78 54  
  55 + eth@80000000 {
  56 + compatible = "sandbox,eth-raw";
  57 + reg = <0x80000000 0x1000>;
  58 + host-raw-interface = "eth0";
  59 + };
  60 +
  61 + eth@90000000 {
  62 + compatible = "sandbox,eth-raw";
  63 + reg = <0x90000000 0x1000>;
  64 + host-raw-interface = "lo";
  65 + };
  66 +
79 67 gpio_a: gpios@0 {
80 68 gpio-controller;
81 69 compatible = "sandbox,gpio";
... ... @@ -92,6 +80,12 @@
92 80 num-gpios = <10>;
93 81 };
94 82  
  83 + hexagon {
  84 + compatible = "demo-simple";
  85 + colour = "white";
  86 + sides = <6>;
  87 + };
  88 +
95 89 i2c_0: i2c@0 {
96 90 #address-cells = <1>;
97 91 #size-cells = <0>;
... ... @@ -120,18 +114,10 @@
120 114 };
121 115 };
122 116  
123   - spi@0 {
124   - #address-cells = <1>;
125   - #size-cells = <0>;
126   - reg = <0 0>;
127   - compatible = "sandbox,spi";
128   - cs-gpios = <0>, <&gpio_a 0>;
129   - firmware_storage_spi: flash@0 {
130   - reg = <0>;
131   - compatible = "spansion,m25p16", "sandbox,spi-flash";
132   - spi-max-frequency = <40000000>;
133   - sandbox,filename = "spi.bin";
134   - };
  117 + lcd {
  118 + compatible = "sandbox,lcd-sdl";
  119 + xres = <1366>;
  120 + yres = <768>;
135 121 };
136 122  
137 123 pci: pci-controller {
138 124  
139 125  
... ... @@ -150,22 +136,38 @@
150 136 };
151 137 };
152 138  
153   - eth@10002000 {
154   - compatible = "sandbox,eth";
155   - reg = <0x10002000 0x1000>;
156   - fake-host-hwaddr = [00 00 66 44 22 00];
  139 + spi@0 {
  140 + #address-cells = <1>;
  141 + #size-cells = <0>;
  142 + reg = <0 0>;
  143 + compatible = "sandbox,spi";
  144 + cs-gpios = <0>, <&gpio_a 0>;
  145 + firmware_storage_spi: flash@0 {
  146 + reg = <0>;
  147 + compatible = "spansion,m25p16", "sandbox,spi-flash";
  148 + spi-max-frequency = <40000000>;
  149 + sandbox,filename = "spi.bin";
  150 + };
157 151 };
158 152  
159   - eth@80000000 {
160   - compatible = "sandbox,eth-raw";
161   - reg = <0x80000000 0x1000>;
162   - host-raw-interface = "eth0";
  153 + square {
  154 + compatible = "demo-shape";
  155 + colour = "blue";
  156 + sides = <4>;
163 157 };
164 158  
165   - eth@90000000 {
166   - compatible = "sandbox,eth-raw";
167   - reg = <0x90000000 0x1000>;
168   - host-raw-interface = "lo";
  159 + triangle {
  160 + compatible = "demo-shape";
  161 + colour = "cyan";
  162 + sides = <3>;
  163 + character = <83>;
  164 + light-gpios = <&gpio_a 2>, <&gpio_b 6 0>;
  165 + };
  166 +
  167 + /* Needs to be available prior to relocation */
  168 + uart0: serial {
  169 + compatible = "sandbox,serial";
  170 + sandbox,text-colour = "cyan";
169 171 };
170 172  
171 173 usb@0 {
arch/sandbox/dts/test.dts
... ... @@ -8,9 +8,13 @@
8 8  
9 9 aliases {
10 10 console = &uart0;
  11 + eth0 = "/eth@10002000";
  12 + eth5 = &eth_5;
11 13 i2c0 = "/i2c@0";
12   - spi0 = "/spi@0";
13 14 pci0 = &pci;
  15 + rtc0 = &rtc_0;
  16 + rtc1 = &rtc_1;
  17 + spi0 = "/spi@0";
14 18 testfdt6 = "/e-test";
15 19 testbus3 = "/some-bus";
16 20 testfdt0 = "/some-bus/c-test@0";
17 21  
... ... @@ -18,18 +22,11 @@
18 22 testfdt3 = "/b-test";
19 23 testfdt5 = "/some-bus/c-test@5";
20 24 testfdt8 = "/a-test";
21   - eth0 = "/eth@10002000";
22   - eth5 = &eth_5;
23 25 usb0 = &usb_0;
24 26 usb1 = &usb_1;
25 27 usb2 = &usb_2;
26 28 };
27 29  
28   - uart0: serial {
29   - compatible = "sandbox,serial";
30   - u-boot,dm-pre-reloc;
31   - };
32   -
33 30 a-test {
34 31 reg = <0>;
35 32 compatible = "denx,u-boot-fdt-test";
... ... @@ -108,6 +105,24 @@
108 105 compatible = "denx,u-boot-fdt-test";
109 106 };
110 107  
  108 + eth@10002000 {
  109 + compatible = "sandbox,eth";
  110 + reg = <0x10002000 0x1000>;
  111 + fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x00>;
  112 + };
  113 +
  114 + eth_5: eth@10003000 {
  115 + compatible = "sandbox,eth";
  116 + reg = <0x10003000 0x1000>;
  117 + fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x11>;
  118 + };
  119 +
  120 + eth@10004000 {
  121 + compatible = "sandbox,eth";
  122 + reg = <0x10004000 0x1000>;
  123 + fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x22>;
  124 + };
  125 +
111 126 gpio_a: base-gpios {
112 127 compatible = "sandbox,gpio";
113 128 gpio-controller;
... ... @@ -140,6 +155,22 @@
140 155 };
141 156 };
142 157  
  158 + rtc_0: rtc@43 {
  159 + reg = <0x43>;
  160 + compatible = "sandbox-rtc";
  161 + emul {
  162 + compatible = "sandbox,i2c-rtc";
  163 + };
  164 + };
  165 +
  166 + rtc_1: rtc@61 {
  167 + reg = <0x61>;
  168 + compatible = "sandbox-rtc";
  169 + emul {
  170 + compatible = "sandbox,i2c-rtc";
  171 + };
  172 + };
  173 +
143 174 sandbox_pmic: sandbox_pmic {
144 175 reg = <0x40>;
145 176 };
... ... @@ -175,22 +206,9 @@
175 206 };
176 207 };
177 208  
178   - eth@10002000 {
179   - compatible = "sandbox,eth";
180   - reg = <0x10002000 0x1000>;
181   - fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x00>;
182   - };
183   -
184   - eth_5: eth@10003000 {
185   - compatible = "sandbox,eth";
186   - reg = <0x10003000 0x1000>;
187   - fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x11>;
188   - };
189   -
190   - eth@10004000 {
191   - compatible = "sandbox,eth";
192   - reg = <0x10004000 0x1000>;
193   - fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x22>;
  209 + uart0: serial {
  210 + compatible = "sandbox,serial";
  211 + u-boot,dm-pre-reloc;
194 212 };
195 213  
196 214 usb_0: usb@0 {
drivers/pci/pci-uclass.c
... ... @@ -596,6 +596,7 @@
596 596 UCLASS_DRIVER(pci) = {
597 597 .id = UCLASS_PCI,
598 598 .name = "pci",
  599 + .flags = DM_UC_FLAG_SEQ_ALIAS,
599 600 .post_bind = pci_uclass_post_bind,
600 601 .pre_probe = pci_uclass_pre_probe,
601 602 .post_probe = pci_uclass_post_probe,
include/asm-generic/gpio.h
... ... @@ -42,7 +42,7 @@
42 42 * Note: With driver model, the label is allocated so there is no need for
43 43 * the caller to preserve it.
44 44 *
45   - * @param gp GPIO number
  45 + * @param gpio GPIO number
46 46 * @param label User label for this GPIO
47 47 * @return 0 if ok, -1 on error
48 48 */
... ... @@ -127,7 +127,7 @@
127 127 };
128 128  
129 129 /**
130   - * dm_gpio_is_valid() - Check if a GPIO is gpio_is_valie
  130 + * dm_gpio_is_valid() - Check if a GPIO is valid
131 131 *
132 132 * @desc: GPIO description containing device, offset and flags,
133 133 * previously returned by gpio_request_by_name()
... ... @@ -167,7 +167,7 @@
167 167 *
168 168 * @dev: Device to check
169 169 * @offset: Offset of device GPIO to check
170   - * @namep: If non-NULL, this is set to the nane given when the GPIO
  170 + * @namep: If non-NULL, this is set to the name given when the GPIO
171 171 * was requested, or -1 if it has not been requested
172 172 * @return -ENODATA if the driver returned an unknown function,
173 173 * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
... ... @@ -186,7 +186,7 @@
186 186 *
187 187 * @dev: Device to check
188 188 * @offset: Offset of device GPIO to check
189   - * @namep: If non-NULL, this is set to the nane given when the GPIO
  189 + * @namep: If non-NULL, this is set to the name given when the GPIO
190 190 * was requested, or -1 if it has not been requested
191 191 * @return -ENODATA if the driver returned an unknown function,
192 192 * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
... ... @@ -219,7 +219,7 @@
219 219 * Also it would be useful to standardise additional functions like
220 220 * pullup, slew rate and drive strength.
221 221 *
222   - * gpio_request)( and gpio_free() are optional - if NULL then they will
  222 + * gpio_request() and gpio_free() are optional - if NULL then they will
223 223 * not be called.
224 224 *
225 225 * Note that @offset is the offset from the base GPIO of the device. So
... ... @@ -271,7 +271,7 @@
271 271 *
272 272 * @dev: GPIO device
273 273 * @desc: Place to put GPIO description
274   - * @args: Arguments provided in descripion
  274 + * @args: Arguments provided in description
275 275 * @return 0 if OK, -ve on error
276 276 */
277 277 int (*xlate)(struct udevice *dev, struct gpio_desc *desc,
... ... @@ -398,7 +398,7 @@
398 398 /**
399 399 * gpio_request_list_by_name() - Request a list of GPIOs
400 400 *
401   - * Reads all the GPIOs from a list and requetss them. See
  401 + * Reads all the GPIOs from a list and requests them. See
402 402 * gpio_request_by_name() for additional details. Lists should not be
403 403 * misused to hold unrelated or optional GPIOs. They should only be used
404 404 * for things like parallel data lines. A zero phandle terminates the list
... ... @@ -533,7 +533,7 @@
533 533 /**
534 534 * gpio_get_number() - Get the global GPIO number of a GPIO
535 535 *
536   - * This should only be used for debugging or interest. It returns the nummber
  536 + * This should only be used for debugging or interest. It returns the number
537 537 * that should be used for gpio_get_value() etc. to access this GPIO.
538 538 *
539 539 * @desc: GPIO description containing device, offset and flags,
include/dm/uclass-id.h
... ... @@ -39,19 +39,17 @@
39 39 UCLASS_PCH, /* x86 platform controller hub */
40 40 UCLASS_PCI, /* PCI bus */
41 41 UCLASS_PCI_GENERIC, /* Generic PCI bus device */
  42 + UCLASS_PMIC, /* PMIC I/O device */
  43 + UCLASS_REGULATOR, /* Regulator device */
42 44 UCLASS_RTC, /* Real time clock device */
43 45 UCLASS_SERIAL, /* Serial UART */
44 46 UCLASS_SPI, /* SPI bus */
45   - UCLASS_SPI_GENERIC, /* Generic SPI flash target */
46 47 UCLASS_SPI_FLASH, /* SPI flash */
  48 + UCLASS_SPI_GENERIC, /* Generic SPI flash target */
47 49 UCLASS_THERMAL, /* Thermal sensor */
48 50 UCLASS_USB, /* USB bus */
49 51 UCLASS_USB_DEV_GENERIC, /* USB generic device */
50 52 UCLASS_USB_HUB, /* USB hub */
51   -
52   - /* Power Management */
53   - UCLASS_PMIC, /* PMIC I/O device */
54   - UCLASS_REGULATOR, /* REGULATOR device */
55 53  
56 54 UCLASS_COUNT,
57 55 UCLASS_INVALID = -1,
... ... @@ -112,6 +112,14 @@
112 112 void os_tty_raw(int fd, bool allow_sigs);
113 113  
114 114 /**
  115 + * Restore the tty to its original mode
  116 + *
  117 + * Call this to restore the original terminal mode, after it has been changed
  118 + * by os_tty_raw(). This is an internal function.
  119 + */
  120 +void os_fd_restore(void);
  121 +
  122 +/**
115 123 * Acquires some memory from the underlying os.
116 124 *
117 125 * \param length Number of bytes to be allocated
... ... @@ -21,6 +21,17 @@
21 21 }
22 22 DM_TEST(dm_test_pci_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
23 23  
  24 +/* Test that sandbox PCI bus numbering works correctly */
  25 +static int dm_test_pci_busnum(struct unit_test_state *uts)
  26 +{
  27 + struct udevice *bus;
  28 +
  29 + ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 0, &bus));
  30 +
  31 + return 0;
  32 +}
  33 +DM_TEST(dm_test_pci_busnum, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  34 +
24 35 /* Test that we can use the swapcase device correctly */
25 36 static int dm_test_pci_swapcase(struct unit_test_state *uts)
26 37 {