Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Simon Glass | ac0cce5 | 2016-03-11 22:07:23 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016 Google, Inc |
| 4 | * |
| 5 | * From coreboot broadwell support |
Simon Glass | ac0cce5 | 2016-03-11 22:07:23 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
Simon Glass | ac0cce5 | 2016-03-11 22:07:23 -0700 | [diff] [blame] | 8 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | ac0cce5 | 2016-03-11 22:07:23 -0700 | [diff] [blame] | 10 | #include <pch.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | #include <asm/global_data.h> |
Simon Glass | ac0cce5 | 2016-03-11 22:07:23 -0700 | [diff] [blame] | 12 | #include <asm/intel_regs.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/lpc_common.h> |
| 15 | #include <asm/arch/pch.h> |
| 16 | #include <asm/arch/spi.h> |
| 17 | |
| 18 | static void set_spi_speed(void) |
| 19 | { |
| 20 | u32 fdod; |
| 21 | u8 ssfc; |
| 22 | |
| 23 | /* Observe SPI Descriptor Component Section 0 */ |
| 24 | writel(0x1000, SPI_REG(SPIBAR_FDOC)); |
| 25 | |
| 26 | /* Extract the Write/Erase SPI Frequency from descriptor */ |
| 27 | fdod = readl(SPI_REG(SPIBAR_FDOD)); |
| 28 | fdod >>= 24; |
| 29 | fdod &= 7; |
| 30 | |
| 31 | /* Set Software Sequence frequency to match */ |
| 32 | ssfc = readb(SPI_REG(SPIBAR_SSFC + 2)); |
| 33 | ssfc &= ~7; |
| 34 | ssfc |= fdod; |
| 35 | writeb(ssfc, SPI_REG(SPIBAR_SSFC + 2)); |
| 36 | } |
| 37 | |
| 38 | static int broadwell_lpc_early_init(struct udevice *dev) |
| 39 | { |
| 40 | set_spi_speed(); |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | static int lpc_init_extra(struct udevice *dev) |
| 46 | { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static int broadwell_lpc_probe(struct udevice *dev) |
| 51 | { |
| 52 | int ret; |
| 53 | |
| 54 | if (!(gd->flags & GD_FLG_RELOC)) { |
| 55 | ret = lpc_common_early_init(dev); |
| 56 | if (ret) { |
| 57 | debug("%s: lpc_early_init() failed\n", __func__); |
| 58 | return ret; |
| 59 | } |
| 60 | |
| 61 | return broadwell_lpc_early_init(dev); |
| 62 | } |
| 63 | |
| 64 | return lpc_init_extra(dev); |
| 65 | } |
| 66 | |
| 67 | static const struct udevice_id broadwell_lpc_ids[] = { |
| 68 | { .compatible = "intel,broadwell-lpc" }, |
| 69 | { } |
| 70 | }; |
| 71 | |
| 72 | U_BOOT_DRIVER(broadwell_lpc_drv) = { |
| 73 | .name = "lpc", |
| 74 | .id = UCLASS_LPC, |
| 75 | .of_match = broadwell_lpc_ids, |
| 76 | .probe = broadwell_lpc_probe, |
| 77 | }; |