1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * (C) Copyright ASPEED Technology Inc. 4 */ 5 #include <common.h> 6 #include <clk.h> 7 #include <dm/device.h> 8 #include <dm/fdtaddr.h> 9 10 struct aspeed_acry { 11 struct clk clk; 12 }; 13 14 static int aspeed_acry_probe(struct udevice *dev) 15 { 16 struct aspeed_acry *acry = dev_get_priv(dev); 17 int ret; 18 19 ret = clk_get_by_index(dev, 0, &acry->clk); 20 if (ret < 0) { 21 debug("Can't get clock for %s: %d\n", dev->name, ret); 22 return ret; 23 } 24 25 ret = clk_enable(&acry->clk); 26 if (ret) { 27 debug("Failed to enable acry clock (%d)\n", ret); 28 return ret; 29 } 30 31 return ret; 32 } 33 34 static int aspeed_acry_remove(struct udevice *dev) 35 { 36 struct aspeed_acry *acry = dev_get_priv(dev); 37 38 clk_disable(&acry->clk); 39 40 return 0; 41 } 42 43 static const struct udevice_id aspeed_acry_ids[] = { 44 { .compatible = "aspeed,ast2600-acry" }, 45 { } 46 }; 47 48 U_BOOT_DRIVER(aspeed_acry) = { 49 .name = "aspeed_acry", 50 .id = UCLASS_MISC, 51 .of_match = aspeed_acry_ids, 52 .probe = aspeed_acry_probe, 53 .remove = aspeed_acry_remove, 54 .priv_auto_alloc_size = sizeof(struct aspeed_acry), 55 .flags = DM_FLAG_PRE_RELOC, 56 }; 57