Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 2 | |
Martin Roth | cddd600 | 2019-09-23 17:38:27 -0600 | [diff] [blame] | 3 | /* Driver for BayHub Technology BH720 PCI to eMMC 5.0 HS200 bridge */ |
| 4 | |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <device/path.h> |
| 8 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 9 | #include <device/pci_ops.h> |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 10 | #include <device/pci_ids.h> |
| 11 | #include "chip.h" |
Kevin Chiu | 089b685 | 2018-08-03 18:52:18 +0800 | [diff] [blame] | 12 | #include "bh720.h" |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 13 | |
Kevin Chiu | 328ff7d | 2018-08-27 11:44:46 +0800 | [diff] [blame] | 14 | __attribute__((weak)) void board_bh720(struct device *dev) |
Kevin Chiu | 089b685 | 2018-08-03 18:52:18 +0800 | [diff] [blame] | 15 | { |
| 16 | } |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 17 | |
| 18 | static void bh720_init(struct device *dev) |
| 19 | { |
| 20 | struct drivers_generic_bayhub_config *config = dev->chip_info; |
| 21 | |
| 22 | pci_dev_init(dev); |
| 23 | |
| 24 | if (config && config->power_saving) { |
| 25 | /* |
| 26 | * This procedure for enabling power-saving mode is from the |
| 27 | * BayHub BIOS Implementation Guideline document. |
| 28 | */ |
Simon Glass | 4f16049 | 2018-05-23 15:34:04 -0600 | [diff] [blame] | 29 | pci_write_config32(dev, BH720_PROTECT, |
| 30 | BH720_PROTECT_OFF | BH720_PROTECT_LOCK_OFF); |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 31 | pci_or_config32(dev, BH720_RTD3_L1, BH720_RTD3_L1_DISABLE_L1); |
| 32 | pci_or_config32(dev, BH720_LINK_CTRL, |
| 33 | BH720_LINK_CTRL_L0_ENABLE | |
| 34 | BH720_LINK_CTRL_L1_ENABLE); |
| 35 | pci_or_config32(dev, BH720_LINK_CTRL, BH720_LINK_CTRL_CLKREQ); |
Simon Glass | 4f16049 | 2018-05-23 15:34:04 -0600 | [diff] [blame] | 36 | pci_update_config32(dev, BH720_MISC2, ~BH720_MISC2_ASPM_DISABLE, |
| 37 | BH720_MISC2_APSM_CLKREQ_L1 | |
| 38 | BH720_MISC2_APSM_PHY_L1); |
| 39 | pci_write_config32(dev, BH720_PROTECT, |
| 40 | BH720_PROTECT_ON | BH720_PROTECT_LOCK_ON); |
| 41 | |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 42 | printk(BIOS_INFO, "BayHub BH720: Power-saving enabled (link_ctrl=%#x)\n", |
| 43 | pci_read_config32(dev, BH720_LINK_CTRL)); |
| 44 | } |
Kevin Chiu | 089b685 | 2018-08-03 18:52:18 +0800 | [diff] [blame] | 45 | |
Kevin Chiu | 328ff7d | 2018-08-27 11:44:46 +0800 | [diff] [blame] | 46 | board_bh720(dev); |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static struct pci_operations pci_ops = { |
| 50 | .set_subsystem = pci_dev_set_subsystem, |
| 51 | }; |
| 52 | |
| 53 | static struct device_operations bh720_ops = { |
| 54 | .read_resources = pci_dev_read_resources, |
| 55 | .set_resources = pci_dev_set_resources, |
| 56 | .enable_resources = pci_dev_enable_resources, |
| 57 | .ops_pci = &pci_ops, |
| 58 | .init = bh720_init, |
| 59 | }; |
| 60 | |
| 61 | static const unsigned short pci_device_ids[] = { |
| 62 | PCI_DEVICE_ID_O2_BH720, |
| 63 | 0 |
| 64 | }; |
| 65 | |
| 66 | static const struct pci_driver bayhub_bh720 __pci_driver = { |
| 67 | .ops = &bh720_ops, |
| 68 | .vendor = PCI_VENDOR_ID_O2, |
| 69 | .devices = pci_device_ids, |
| 70 | }; |
| 71 | |
Kyösti Mälkki | 08c76e1 | 2019-08-25 13:05:46 +0300 | [diff] [blame] | 72 | struct chip_operations drivers_generic_bayhub_ops = { |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 73 | CHIP_NAME("BayHub Technology BH720 PCI to eMMC 5.0 HS200 bridge") |
Simon Glass | 38d875f | 2018-04-30 14:08:31 -0600 | [diff] [blame] | 74 | }; |