~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/skiboot/hw/fsp/fsp-chiptod.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2013-2014 IBM Corp.
 
2
 *
 
3
 * Licensed under the Apache License, Version 2.0 (the "License");
 
4
 * you may not use this file except in compliance with the License.
 
5
 * You may obtain a copy of the License at
 
6
 *
 
7
 *      http://www.apache.org/licenses/LICENSE-2.0
 
8
 *
 
9
 * Unless required by applicable law or agreed to in writing, software
 
10
 * distributed under the License is distributed on an "AS IS" BASIS,
 
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
12
 * implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
#define pr_fmt(fmt)     "CHIPTOD: " fmt
 
18
 
 
19
#include <skiboot.h>
 
20
#include <chiptod.h>
 
21
#include <fsp.h>
 
22
 
 
23
/* Response status for fsp command 0xE6, s/c 0x06 (Enable/Disable Topology) */
 
24
#define FSP_STATUS_TOPO_IN_USE  0xb8            /* topology is in use */
 
25
 
 
26
static bool fsp_chiptod_update_topology(uint32_t cmd_sub_mod,
 
27
                                        struct fsp_msg *msg)
 
28
{
 
29
        struct fsp_msg *resp;
 
30
        enum chiptod_topology topo;
 
31
        bool action;
 
32
        uint8_t status = 0;
 
33
 
 
34
        switch (cmd_sub_mod) {
 
35
        case FSP_CMD_TOPO_ENABLE_DISABLE:
 
36
                /*
 
37
                 * Action Values: 0x00 = Disable, 0x01 = Enable
 
38
                 * Topology Values: 0x00 = Primary, 0x01 = Secondary
 
39
                 */
 
40
                action = !!msg->data.bytes[2];
 
41
                topo = msg->data.bytes[3];
 
42
                prlog(PR_DEBUG, "Topology update event:\n");
 
43
                prlog(PR_DEBUG, "  Action = %s, Topology = %s\n",
 
44
                                        action ? "Enable" : "Disable",
 
45
                                        topo ? "Secondary" : "Primary");
 
46
 
 
47
                if (!chiptod_adjust_topology(topo, action))
 
48
                        status = FSP_STATUS_TOPO_IN_USE;
 
49
                else
 
50
                        status = 0x00;
 
51
 
 
52
                resp = fsp_mkmsg(FSP_RSP_TOPO_ENABLE_DISABLE | status, 0);
 
53
                if (!resp) {
 
54
                        prerror("Response allocation failed\n");
 
55
                        return false;
 
56
                }
 
57
                if (fsp_queue_msg(resp, fsp_freemsg)) {
 
58
                        fsp_freemsg(resp);
 
59
                        prerror("Failed to queue response msg\n");
 
60
                }
 
61
                return true;
 
62
        default:
 
63
                prlog(PR_DEBUG, "Unhandled sub cmd: %06x\n", cmd_sub_mod);
 
64
                break;
 
65
        }
 
66
        return false;
 
67
}
 
68
 
 
69
static struct fsp_client fsp_chiptod_client = {
 
70
                .message = fsp_chiptod_update_topology,
 
71
};
 
72
 
 
73
void fsp_chiptod_init(void)
 
74
{
 
75
        /* Register for Class E6 (HW maintanance) */
 
76
        fsp_register_client(&fsp_chiptod_client, FSP_MCLASS_HW_MAINT);
 
77
}