Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Atmel Corporation |
| 4 | * Wenyou Yang <wenyou.yang@atmel.com> |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 9 | #include <asm/arch/clk.h> |
| 10 | #include <asm/arch/sama5d2.h> |
| 11 | |
Alexander Dahl | 3f77506 | 2019-03-22 14:25:54 +0100 | [diff] [blame] | 12 | int _cpu_is_sama5d2(void) |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 13 | { |
Wenyou Yang | 9366fd0 | 2017-09-13 14:58:53 +0800 | [diff] [blame] | 14 | unsigned int chip_id = get_chip_id(); |
| 15 | |
| 16 | return ((chip_id == ARCH_ID_SAMA5D2) || |
| 17 | (chip_id == ARCH_ID_SAMA5D2_SIP)) ? 1 : 0; |
| 18 | } |
| 19 | |
| 20 | char *get_cpu_name(void) |
| 21 | { |
| 22 | unsigned int chip_id = get_chip_id(); |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 23 | unsigned int extension_id = get_extension_chip_id(); |
| 24 | |
Wenyou Yang | 9366fd0 | 2017-09-13 14:58:53 +0800 | [diff] [blame] | 25 | if (chip_id == ARCH_ID_SAMA5D2) { |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 26 | switch (extension_id) { |
| 27 | case ARCH_EXID_SAMA5D21CU: |
| 28 | return "SAMA5D21"; |
| 29 | case ARCH_EXID_SAMA5D22CU: |
| 30 | return "SAMA5D22-CU"; |
| 31 | case ARCH_EXID_SAMA5D22CN: |
| 32 | return "SAMA5D22-CN"; |
| 33 | case ARCH_EXID_SAMA5D23CU: |
| 34 | return "SAMA5D23-CU"; |
| 35 | case ARCH_EXID_SAMA5D24CX: |
| 36 | return "SAMA5D24-CX"; |
| 37 | case ARCH_EXID_SAMA5D24CU: |
| 38 | return "SAMA5D24-CU"; |
| 39 | case ARCH_EXID_SAMA5D26CU: |
| 40 | return "SAMA5D26-CU"; |
| 41 | case ARCH_EXID_SAMA5D27CU: |
| 42 | return "SAMA5D27-CU"; |
| 43 | case ARCH_EXID_SAMA5D27CN: |
| 44 | return "SAMA5D27-CN"; |
| 45 | case ARCH_EXID_SAMA5D28CU: |
| 46 | return "SAMA5D28-CU"; |
| 47 | case ARCH_EXID_SAMA5D28CN: |
| 48 | return "SAMA5D28-CN"; |
Hari Prasath | 03ecb90 | 2021-07-14 19:13:41 +0530 | [diff] [blame] | 49 | case ARCH_EXID_SAMA5D29CN: |
| 50 | return "SAMA5D29-CN"; |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | |
Wenyou Yang | 9366fd0 | 2017-09-13 14:58:53 +0800 | [diff] [blame] | 54 | if ((chip_id == ARCH_ID_SAMA5D2) || (chip_id == ARCH_ID_SAMA5D2_SIP)) { |
| 55 | switch (extension_id) { |
| 56 | case ARCH_EXID_SAMA5D225C_D1M: |
| 57 | return "SAMA5D225 128M bits DDR2 SDRAM"; |
| 58 | case ARCH_EXID_SAMA5D27C_D5M: |
| 59 | return "SAMA5D27 512M bits DDR2 SDRAM"; |
| 60 | case ARCH_EXID_SAMA5D27C_D1G: |
| 61 | return "SAMA5D27 1G bits DDR2 SDRAM"; |
Nicolas Ferre | 08eb7c6 | 2019-08-08 07:48:23 +0000 | [diff] [blame] | 62 | case ARCH_EXID_SAMA5D27C_LD1G: |
| 63 | return "SAMA5D27 1G bits LPDDR2 SDRAM"; |
| 64 | case ARCH_EXID_SAMA5D27C_LD2G: |
| 65 | return "SAMA5D27 2G bits LPDDR2 SDRAM"; |
Wenyou Yang | 9366fd0 | 2017-09-13 14:58:53 +0800 | [diff] [blame] | 66 | case ARCH_EXID_SAMA5D28C_D1G: |
| 67 | return "SAMA5D28 1G bits DDR2 SDRAM"; |
Nicolas Ferre | 08eb7c6 | 2019-08-08 07:48:23 +0000 | [diff] [blame] | 68 | case ARCH_EXID_SAMA5D28C_LD1G: |
| 69 | return "SAMA5D28 1G bits LPDDR2 SDRAM"; |
| 70 | case ARCH_EXID_SAMA5D28C_LD2G: |
| 71 | return "SAMA5D28 2G bits LPDDR2 SDRAM"; |
Wenyou Yang | 9366fd0 | 2017-09-13 14:58:53 +0800 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 75 | return "Unknown CPU type"; |
| 76 | } |
| 77 | |
| 78 | #ifdef CONFIG_USB_GADGET_ATMEL_USBA |
| 79 | void at91_udp_hw_init(void) |
| 80 | { |
Wenyou Yang | b5d886a | 2016-02-02 11:11:52 +0800 | [diff] [blame] | 81 | at91_upll_clk_enable(); |
Wenyou Yang | c64a75a | 2015-10-30 09:55:52 +0800 | [diff] [blame] | 82 | |
| 83 | at91_periph_clk_enable(ATMEL_ID_UDPHS); |
| 84 | } |
| 85 | #endif |