]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - k3conf/k3conf.git/blob - common/cmd_enable.c
soc: am65x_sr2: Add sec proxy info
[k3conf/k3conf.git] / common / cmd_enable.c
1 /*
2  * K3CONF Command Enable
3  *
4  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
5  *      Lokesh Vutla <lokeshvutla@ti.com>
6  *
7  *  Redistribution and use in source and binary forms, with or without
8  *  modification, are permitted provided that the following conditions
9  *  are met:
10  *
11  *    Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  *    Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the
17  *    distribution.
18  *
19  *    Neither the name of Texas Instruments Incorporated nor the names of
20  *    its contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
36 #include <stdlib.h>
37 #include <string.h>
38 #include <stdio.h>
39 #include <tisci.h>
40 #include <socinfo.h>
41 #include <help.h>
42 #include <k3conf.h>
44 static int enable_device(int argc, char *argv[])
45 {
46         uint32_t dev_id, ret;
48         if (argc < 1)
49                 return -1;
51         ret = sscanf(argv[0], "%u", &dev_id);
52         if (ret != 1)
53                 return -1;
55         ret = ti_sci_cmd_enable_device(dev_id);
56         if (ret)
57                 return ret;
59         return dump_devices_info(argc, argv);
60 }
62 static int enable_clock(int argc, char *argv[])
63 {
64         uint32_t dev_id, clk_id, ret;
66         if (argc < 2)
67                 return -1;
69         ret = sscanf(argv[0], "%u", &dev_id);
70         if (ret != 1)
71                 return -1;
73         ret = sscanf(argv[1], "%u", &clk_id);
74         if (ret != 1)
75                 return -1;
77         ret = ti_sci_cmd_get_clk(dev_id, clk_id);
78         if (ret)
79                 return ret;
81         return dump_clocks_info(argc, argv);
82 }
84 int process_enable_command(int argc, char *argv[])
85 {
86         int ret;
88         if (argc < 1) {
89                 help(HELP_ENABLE);
90                 return -1;
91         }
93         if (!strncmp(argv[0], "device", 6)) {
94                 argc--;
95                 argv++;
96                 ret = enable_device(argc, argv);
97                 if (ret) {
98                         fprintf(stderr, "Invalid device arguments\n");
99                         help(HELP_ENABLE_DEVICE);
100                 }
101         } else if (!strncmp(argv[0], "clock", 5)) {
102                 argc--;
103                 argv++;
104                 ret = enable_clock(argc, argv);
105                 if (ret) {
106                         fprintf(stderr, "Invalid clock arguments\n");
107                         help(HELP_ENABLE_CLOCK);
108                 }
109         } else if (!strcmp(argv[0], "--help")) {
110                 help(HELP_ENABLE);
111                 return 0;
112         } else {
113                 fprintf(stderr, "Invalid argument %s\n", argv[1]);
114                 help(HELP_ENABLE);
115                 return -1;
116         }
117         return ret;