|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- U( i; N) C- s' M, W#include <linux/init.h>9 k$ z4 j! y5 j& k+ k
#include <linux/module.h>
, B: ? }1 ~' n+ p7 x#include <linux/kernel.h>
% D: w5 J; D) ~2 d#include <linux/types.h>
1 J/ w- \$ |, G) j#include <linux/gpio.h>
9 C3 `9 e) i+ Q0 S1 C' j#include <linux/leds.h>
. O% { j- O# E5 i5 k#include <linux/platform_device.h>
8 x1 Y5 s4 a1 M7 [% ?5 v* O! j$ j6 R2 h
#include <asm/mach-types.h>
4 h' m0 x6 W! Q) i7 i4 C% T2 a1 d#include <asm/mach/arch.h>5 H# G/ `% v* i7 M3 v
#include <mach/da8xx.h>
/ P: Q( T, V' Z1 L& T#include <mach/mux.h>! A9 U, v6 \/ B2 P' P- Z* e
) b+ b% A# }9 G$ \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" k R9 c3 \( w/ _7 p. ^# @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 h5 G* ]5 C/ J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' D. |" a. Q) G0 Z/ z; R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; m' e! V }& d: W5 g+ S5 u$ g3 k8 V. C
- O! a; }& l& t& K- `/* assign the tl som board LED-GPIOs*/7 ~$ x5 o6 ^3 O& W2 Z7 n
static const short da850_evm_tl_user_led_pins[] = {
; w+ q0 {* e7 F, Y /* These pins are definition at <mach/mux.h> file *// Y; d0 r, ~, n- W* i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* h; R6 t0 l! T$ @6 {, i( W/ R' ? -1
3 E2 P- {0 v' k};
2 w) |( t$ _, K1 {# a' Y9 q: P7 z4 h. z2 \6 `8 T2 s: N
static struct gpio_led da850_evm_tl_leds[] = {# Y+ T* F9 g! z3 G
{
' I m, ?/ U' X9 ~! E8 P1 @ .active_low = 0,/ ^5 b) w5 y. W) K. g3 E
.gpio = DA850_USER_LED0,9 `1 ]) d& A8 D, G# p6 G
.name = "user_led0",) @1 x7 S9 d$ K; X6 C6 {
.default_trigger = "default-on",4 \7 H+ v4 Z% W$ o; }
},4 U2 \( j# L9 x, j e4 U, n
{
" O. n1 j4 P8 S7 S- o .active_low = 0,- p& u9 }( y9 [( B1 Z
.gpio = DA850_USER_LED1,
! c. G! b, H( A7 O3 O .name = "user_led1",
) v# t; E% ~' G: k) } .default_trigger = "default-on",
+ X: }% D- F. \9 j: r5 ?) ^ },1 J# A. [7 ] A$ o. G4 Z
{
* }: U" B! F g$ j9 Y* j .active_low = 0,5 m! ^# k1 [- D( u) [% x. E W
.gpio = DA850_USER_LED2,0 S* ~( O0 S- q) J0 [
.name = "user_led2",$ k' E) Q! l0 b, D
.default_trigger = "default-on",
, q3 M$ V& f2 P3 ]6 p" t6 T },
! I6 o1 P% i. B1 [- q2 y6 q' E2 h {
& V& f! M" Y5 ]0 v- L8 S ^+ F .active_low = 0,
$ o+ a* ?' c0 P* U: o+ i4 u. x. X# o .gpio = DA850_USER_LED3,( ?8 L" X, [0 J8 [
.name = "user_led3",
4 L4 h5 Y2 C( c) o .default_trigger = "default-on",& M- E. j5 F. ]
},
" [+ K& Y- q8 Z; ?) ]};3 [) N5 N" J4 w. p7 t5 m
( A ~: b3 h( ^2 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: Y' @* j; b2 [+ |9 o% o .leds = da850_evm_tl_leds,; i/ `9 {! S# h( j4 E% |5 S2 ?) h! g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 s0 A2 ^* ?" p/ t9 `1 J6 t
};7 ]5 f4 k3 U" J! l0 h$ o
% A7 V) r/ S# V* F8 }: E% G# m X* R5 U
static void led_dev_release(struct device *dev)
+ j) \2 P: m* n2 S+ G! H" D{& ^" r1 p, g/ t& }
}; \5 j; U/ i1 p' ?' U
+ j% {$ ^* B% o& a# z, L2 b; Gstatic struct platform_device da850_evm_tl_leds_device = { \3 I: X5 y, R) b+ _# S
.name = "leds-gpio",+ _8 f+ K+ N3 q7 L0 i
.id = 1,
3 q9 k% p' C0 Q. g% {3 P; E$ X; u7 V) ] .dev = {
: ` L9 s7 m6 q' d& P' r .platform_data = &da850_evm_tl_leds_pdata,
1 \: K5 J! e1 o/ g .release = led_dev_release,4 o; c8 ]3 T1 `3 c) H( W9 Z
}
: W) k b# v5 Z* Y* n) g};4 k' U; a0 S+ o0 z, z
0 J- m+ h- v. j
static int __init led_platform_init(void)
, ~! z8 O. U2 n{% ~# N' I+ ~+ R( e; J1 k( `- z
int ret;
, o" H7 C3 \" d#if 0& M& Z9 O1 z9 A/ k Y5 f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 ]; q* v4 L* n4 p( `0 P* E" n: n1 z0 x
if (ret)
) j. H. p! h) L' n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 E Y. `: d, r7 }8 X
"%d\n", ret);
5 H2 R$ \& D' E' ?* B6 c#endif' B2 t/ Y6 G5 h
ret = platform_device_register(&da850_evm_tl_leds_device);
" i- s1 Y9 r+ |" H9 K" X if (ret)+ |" S0 B: {: J+ _$ k% [+ K
pr_warning("Could not register som GPIO expander LEDS");* ]" {6 ?) I/ w% a" m
else) e6 Y+ J4 h, `" {& s1 x0 Q, X) W- V
printk(KERN_INFO "LED register sucessful!\n");# O. \4 G2 z. {, a1 e# o @
8 P: l+ z- U9 x/ j1 x% Z return ret;
3 @% Y# c2 p1 e5 A( g. b# L}& l) s. z, O# p, Y R
, x E" ~% D+ K4 u6 g v. ~
static void __exit led_platform_exit(void)
% w9 z& J, e) j& b* e% o# J{
& \7 |; s' G" L& W" v; z platform_device_unregister(&da850_evm_tl_leds_device);
8 D, p% n) z/ S: V7 j: g8 H7 l) y: A. ^1 r" F
printk(KERN_INFO "LED unregister!\n");/ N8 G! K& f, x# y9 o. v# R" h- ?3 ^# l
}
+ m% ?6 h8 G, H: }9 X G+ B0 u! |/ g/ F1 K
module_init(led_platform_init);
V) I# e& q, wmodule_exit(led_platform_exit);
! x& x1 ?' }" ], n4 K; U n0 e) J. w* K: M, g7 c
MODULE_DESCRIPTION("Led platform driver");
* H) m3 b& Y3 Y. r' ]; g& LMODULE_AUTHOR("Tronlong");, Z1 w& t6 c; {
MODULE_LICENSE("GPL");
' {: e* V1 U" T% [3 S, J4 O0 E" Z
|
|